@Target(value={ANNOTATION_TYPE,METHOD})
@Retention(value=RUNTIME)
@ExtendWith(value=org.junitpioneer.vintage.ExpectedExceptionExtension.class) @ExtendWith(value=org.junitpioneer.vintage.TimeoutExtension.class)
@Test
public @interface Test
@Test
is used to signal to JUnit Jupiter that the annotated method is a test method - it is designed
to be a drop-in replacement for JUnit 4's @Test
.
Like JUnit 4's annotation it offers the possibility to expect exceptions
and to
time out
long running tests. The latter functions slightly different from the original - see the
attached Javadoc.
See the official @Test
for more information regarding JUnit Jupiter integration.
Modifier and Type | Optional Element and Description |
---|---|
java.lang.Class<? extends java.lang.Throwable> |
expected
Optionally specify
expected , a Throwable, to cause a test method to succeed if
and only if an exception of the specified class is thrown by the method. |
long |
timeout
Optionally specify
timeout in milliseconds to cause a test method to fail if it
takes longer than that number of milliseconds. |
public abstract java.lang.Class<? extends java.lang.Throwable> expected
expected
, a Throwable, to cause a test method to succeed if
and only if an exception of the specified class is thrown by the method.public abstract long timeout
timeout
in milliseconds to cause a test method to fail if it
takes longer than that number of milliseconds.
NOTE: Unlike the same parameter on JUnit 4's @Test
annotation, this one
does not lead to a long running test being abandoned.
Tests will always be allowed to finish (if they do that at all) and their run time might lead
to the test being failed retroactively.