use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestWatcherTests method testWatcherIsInvokedForRepeatedTestMethods.
@Test
void testWatcherIsInvokedForRepeatedTestMethods() {
EngineExecutionResults results = executeTestsForClass(TrackingTestWatcherRepeatedTestMethodsTestCase.class);
results.containerEvents().assertStatistics(stats -> stats.skipped(1).started(5).succeeded(5).aborted(0).failed(0));
results.testEvents().assertStatistics(stats -> stats.dynamicallyRegistered(6).skipped(0).started(6).succeeded(2).aborted(2).failed(2));
ArrayList<String> expectedMethods = new ArrayList<>(testWatcherMethodNames);
// Since the @RepeatedTest container is disabled, the individual invocations never occur.
assertThat(TrackingTestWatcher.results.keySet()).containsAll(expectedMethods);
// 2 => number of iterations declared in @RepeatedTest(2).
TrackingTestWatcher.results.forEach((methodName, uidList) -> assertEquals("testDisabled".endsWith(methodName) ? 1 : 2, uidList.size()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestWatcherTests method testWatcherInvokedForTestMethodsInTestCaseWithProblematicConstructor.
@Test
void testWatcherInvokedForTestMethodsInTestCaseWithProblematicConstructor() {
EngineExecutionResults results = executeTestsForClass(ProblematicConstructorTestCase.class);
results.testEvents().assertStatistics(stats -> stats.skipped(0).started(8).succeeded(0).aborted(0).failed(8));
assertThat(TrackingTestWatcher.results.keySet()).containsExactly("testFailed");
assertThat(TrackingTestWatcher.results.get("testFailed")).hasSize(8);
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TimeoutExtensionTests method appliesTimeoutOnAnnotatedTestMethods.
@Test
@DisplayName("is applied on annotated @Test methods")
void appliesTimeoutOnAnnotatedTestMethods() {
EngineExecutionResults results = executeTests(//
request().selectors(//
selectMethod(TimeoutAnnotatedTestMethodTestCase.class, "testMethod")).configurationParameter(DEFAULT_TEST_METHOD_TIMEOUT_PROPERTY_NAME, //
"42ns").build());
Execution execution = findExecution(results.testEvents(), "testMethod()");
//
assertThat(execution.getDuration()).isGreaterThanOrEqualTo(//
Duration.ofMillis(10)).isLessThan(Duration.ofSeconds(1));
//
assertThat(execution.getTerminationInfo().getExecutionResult().getThrowable().orElseThrow()).isInstanceOf(//
TimeoutException.class).hasMessage("testMethod() timed out after 10 milliseconds");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TimeoutExtensionTests method doesNotApplyTimeoutOnAnnotatedTestMethodsUsingDisabledTimeoutMode.
@Test
@DisplayName("is not applied on annotated @Test methods using timeout mode: disabled")
void doesNotApplyTimeoutOnAnnotatedTestMethodsUsingDisabledTimeoutMode() {
EngineExecutionResults results = executeTests(//
request().selectors(//
selectMethod(TimeoutAnnotatedTestMethodTestCase.class, "testMethod")).configurationParameter(DEFAULT_TEST_METHOD_TIMEOUT_PROPERTY_NAME, //
"42ns").configurationParameter(TIMEOUT_MODE_PROPERTY_NAME, "disabled").build());
Execution execution = findExecution(results.testEvents(), "testMethod()");
//
assertThat(execution.getTerminationInfo().getExecutionResult().getThrowable()).isEmpty();
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TimeoutExtensionTests method appliesTimeoutOnAnnotatedTestFactoryMethods.
@Test
@DisplayName("is applied on annotated @TestFactory methods")
void appliesTimeoutOnAnnotatedTestFactoryMethods() {
EngineExecutionResults results = executeTests(//
request().selectors(//
selectMethod(TimeoutAnnotatedTestMethodTestCase.class, "testFactoryMethod")).configurationParameter(DEFAULT_TEST_FACTORY_METHOD_TIMEOUT_PROPERTY_NAME, //
"42ns").build());
Execution execution = findExecution(results.containerEvents(), "testFactoryMethod()");
//
assertThat(execution.getDuration()).isGreaterThanOrEqualTo(//
Duration.ofMillis(10)).isLessThan(Duration.ofSeconds(1));
//
assertThat(execution.getTerminationInfo().getExecutionResult().getThrowable().orElseThrow()).isInstanceOf(//
TimeoutException.class).hasMessage("testFactoryMethod() timed out after 10 milliseconds");
}
Aggregations