use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DisabledTests method executeTestsWithDisabledTestClass.
@Test
void executeTestsWithDisabledTestClass() {
LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestClassTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getContainerSkippedCount(), "# container skipped");
assertEquals(0, eventRecorder.getTestStartedCount(), "# tests started");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DisabledTests method executeTestsWithDisabledTestMethods.
@Test
void executeTestsWithDisabledTestMethods() throws Exception {
LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestMethodsTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(1, eventRecorder.getTestSkippedCount(), "# tests skipped");
String method = DisabledTestMethodsTestCase.class.getDeclaredMethod("disabledTest").toString();
String reason = eventRecorder.getSkippedTestEvents().get(0).getPayload(String.class).get();
assertEquals(method + " is @Disabled", reason);
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DynamicNodeGenerationTests method dynamicContainersChildrenMustNotBeNull.
@Test
void dynamicContainersChildrenMustNotBeNull() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithNullChildren")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("dynamicContainerWithNullChildren"), started()), //
event(dynamicTestRegistered("dynamic-container:#1")), //
event(container("dynamic-container:#1"), started()), event(//
container("dynamic-container:#1"), //
finishedWithFailure(message("individual dynamic node must not be null"))), //
event(container("dynamicContainerWithNullChildren"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DynamicNodeGenerationTests method dynamicContainersAreExecutedFromExceptionThrowingStream.
@Test
void dynamicContainersAreExecutedFromExceptionThrowingStream() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithExceptionThrowingStream")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertTrue(MyDynamicTestCase.exceptionThrowingStreamClosed.get(), "stream should be closed");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("dynamicContainerWithExceptionThrowingStream"), started()), //
event(dynamicTestRegistered("dynamic-container:#1")), //
event(container("dynamic-container:#1"), started()), //
event(dynamicTestRegistered("dynamic-test:#1")), //
event(test("dynamic-test:#1", "succeedingTest"), started()), //
event(test("dynamic-test:#1", "succeedingTest"), finishedSuccessfully()), //
event(dynamicTestRegistered("dynamic-test:#2")), //
event(test("dynamic-test:#2", "failingTest"), started()), //
event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), //
event(container("dynamic-container:#1"), finishedWithFailure(isA(ArrayIndexOutOfBoundsException.class))), //
event(container("dynamicContainerWithExceptionThrowingStream"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
assertAll(() -> assertEquals(4, eventRecorder.getContainerStartedCount(), "# container started"), () -> assertEquals(3, eventRecorder.getDynamicTestRegisteredCount(), "# dynamic tests registered"), () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed"), () -> assertEquals(4, eventRecorder.getContainerFinishedCount(), "# container finished"));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class DynamicNodeGenerationTests method legacyReportingNames.
@Test
void legacyReportingNames() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "nestedDynamicContainers")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
// @formatter:off
Stream<String> legacyReportingNames = eventRecorder.getExecutionEvents().stream().filter(event -> event.getType() == DYNAMIC_TEST_REGISTERED).map(ExecutionEvent::getTestDescriptor).map(TestDescriptor::getLegacyReportingName);
// @formatter:off
assertThat(legacyReportingNames).containsExactly("nestedDynamicContainers()[1]", "nestedDynamicContainers()[1][1]", "nestedDynamicContainers()[1][1][1]", "nestedDynamicContainers()[1][1][2]");
}
Aggregations