use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestCaseWithInheritanceTests method executeTestDeclaredInSuperClass.
@Test
void executeTestDeclaredInSuperClass() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(LocalTestCase.class, "superTest")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests skipped");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests aborted");
assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed");
assertEquals(1, LocalTestCase.countBeforeInvoked, "# after calls");
assertEquals(1, LocalTestCase.countAfterInvoked, "# after calls");
assertEquals(1, AbstractTestCase.countSuperBeforeInvoked, "# super before calls");
assertEquals(1, AbstractTestCase.countSuperAfterInvoked, "# super after calls");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestCaseWithInheritanceTests method executeTestWithExceptionThrownInAfterMethod.
@Test
void executeTestWithExceptionThrownInAfterMethod() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(LocalTestCase.class, "throwExceptionInAfterMethod")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(0, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests skipped");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests aborted");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestInstanceLifecycleConfigurationTests method performAssertions.
private void performAssertions(Class<?> testClass, Map<String, String> configParams, int containers, int failedContainers, int tests, String... methods) {
// @formatter:off
ExecutionEventRecorder eventRecorder = executeTests(request().selectors(selectClass(testClass)).configurationParameters(configParams).build());
assertAll(() -> assertEquals(containers, eventRecorder.getContainerStartedCount(), "# containers started"), () -> assertEquals(containers, eventRecorder.getContainerFinishedCount(), "# containers finished"), () -> assertEquals(failedContainers, eventRecorder.getContainerFailedCount(), "# containers failed"), () -> assertEquals(tests, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(tests, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(Arrays.asList(methods), methodsInvoked));
// @formatter:on
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestTemplateInvocationTests method templateWithTwoInvocationsFromSingleExtensionIsInvoked.
@Test
void templateWithTwoInvocationsFromSingleExtensionIsInvoked() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoInvocationsFromSingleExtension")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithTwoInvocationsFromSingleExtension"), started()), //
event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1]")), //
event(test("test-template-invocation:#1"), started()), event(test("test-template-invocation:#1"), //
finishedWithFailure(message("invocation is expected to fail"))), //
event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), //
event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), //
finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class TestTemplateInvocationTests method disabledTemplateIsSkipped.
@Test
void disabledTemplateIsSkipped() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "disabledTemplate")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), wrappedInContainerEvents(//
MyTestTemplateTestCase.class, event(container("disabledTemplate"), skippedWithReason("always disabled"))));
}
Aggregations