name.falgout.jeffrey.testing:annotation-processor-testing-junit5

An easier way to verify annotation processor diagnostics.

Лицензия

Лицензия

MIT License
Категории

Категории

JUnit Тестирование компонентов
Группа

Группа

name.falgout.jeffrey.testing
Идентификатор

Идентификатор

annotation-processor-testing-junit5
Последняя версия

Последняя версия

0.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

An easier way to verify annotation processor diagnostics.

Скачать annotation-processor-testing-junit5

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/name.falgout.jeffrey.testing/annotation-processor-testing-junit5/ -->
<dependency>
    <groupId>name.falgout.jeffrey.testing</groupId>
    <artifactId>annotation-processor-testing-junit5</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/name.falgout.jeffrey.testing/annotation-processor-testing-junit5/
implementation 'name.falgout.jeffrey.testing:annotation-processor-testing-junit5:0.2.0'
// https://jarcasting.com/artifacts/name.falgout.jeffrey.testing/annotation-processor-testing-junit5/
implementation ("name.falgout.jeffrey.testing:annotation-processor-testing-junit5:0.2.0")
'name.falgout.jeffrey.testing:annotation-processor-testing-junit5:jar:0.2.0'
<dependency org="name.falgout.jeffrey.testing" name="annotation-processor-testing-junit5" rev="0.2.0">
  <artifact name="annotation-processor-testing-junit5" type="jar" />
</dependency>
@Grapes(
@Grab(group='name.falgout.jeffrey.testing', module='annotation-processor-testing-junit5', version='0.2.0')
)
libraryDependencies += "name.falgout.jeffrey.testing" % "annotation-processor-testing-junit5" % "0.2.0"
[name.falgout.jeffrey.testing/annotation-processor-testing-junit5 "0.2.0"]

Зависимости

compile (6)

Идентификатор библиотеки Тип Версия
name.falgout.jeffrey.testing : annotation-processor-testing jar 0.2.0
org.junit.platform : junit-platform-engine jar
org.junit.platform : junit-platform-commons jar
org.junit.jupiter : junit-jupiter-api jar
com.google.guava : guava jar 24.0-jre
com.google.auto.service : auto-service jar 1.0-rc4

test (4)

Идентификатор библиотеки Тип Версия
name.falgout.jeffrey.testing : annotation-processor-testing-tests jar 0.2.0
name.falgout.jeffrey.testing.junit5 : extension-testing jar 1.0.1
com.google.truth : truth jar 0.40
com.google.truth.extensions : truth-java8-extension jar 0.40

Модули Проекта

Данный проект не имеет модулей.

annotation-processor-testing

An easy way to verify that your annotation processor is emitting the right diagnostics.

Setup

In order to use any of the test runners, you must include your test sources as a resource:

<build>
...
<testResources>
  <testResource>
    <directory>src/test/java/</directory>
  </testResource>
  <testResource>
    <directory>src/test/resources/</directory>
  </testResource>
</testResources>
...
</build>

Additionally, you may need to disable annotation processing during test compilation if you are testing ERROR diagnostics.

<build>
...
<plugins>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <executions>
   <execution>
     <id>default-testCompile</id>
     <goals>
       <goal>testCompile</goal>
     </goals>
     <configuration>
       <proc>none</proc>
     </configuration>
   </execution>
 </executions>
</plugins
...
</build>

Usage

Annotate your test class with @UseProcessor, @ExpectError, and @ExpectDiagnostic:

@UseProcessor(YourProcessor.class)
public class YourProcessorTest {
  @ExpectError @IncorrectlyUsedAnnotation
  public void method() {}

  @ExpectError("substring of the message") @IncorrectlyUsedAnnotation
  public void method1() {}

  @ExpectError(lineOffset = 1) // Expect a diagnostic on the next line.
  @IncorrectlyUsedAnnotation
  public void method2() {}

  @ExpectError(value = "[abc]+", regex = true) @IncorrectlyUsedAnnotation
  public void method3() {}

  @ExpectError(testName = "descriptive JUnit test name") @IncorrectlyUsedAnnotation
  public void method4() {}

  // No @Expect annotation needed.
  @CorrectlyUsedAnnotation
  public void method5() {}
}

JUnit 4

Maven Central

Add @RunWith(DiagnosticTester.class) to your test class.

JUnit 5

Maven Central

Ensure that annotation-processor-testing-junit5 is included as a dependency, and the JUnit 5 launcher should automatically discover your tests.

Версии библиотеки

Версия
0.2.0