use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ExceptionHandlingTests method checkedExceptionInAfterAllIsRegistered.
@Test
void checkedExceptionInAfterAllIsRegistered() throws NoSuchMethodException {
Method method = FailureTestCase.class.getDeclaredMethod("succeedingTest");
LauncherDiscoveryRequest request = request().selectors(selectMethod(FailureTestCase.class, method)).build();
FailureTestCase.exceptionToThrowInAfterAll = Optional.of(new IOException("checked"));
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(FailureTestCase.class), started()), //
event(test("succeedingTest"), started()), //
event(test("succeedingTest"), finishedSuccessfully()), event(container(FailureTestCase.class), //
finishedWithFailure(allOf(isA(IOException.class), message("checked")))), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ExceptionHandlingTests method checkedExceptionInAfterEachIsSuppressedByExceptionInTest.
@Test
void checkedExceptionInAfterEachIsSuppressedByExceptionInTest() throws NoSuchMethodException {
Method method = FailureTestCase.class.getDeclaredMethod("testWithUncheckedException");
LauncherDiscoveryRequest request = request().selectors(selectMethod(FailureTestCase.class, method)).build();
FailureTestCase.exceptionToThrowInAfterEach = Optional.of(new IOException("checked"));
ExecutionEventRecorder eventRecorder = executeTests(request);
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(FailureTestCase.class), started()), //
event(test("testWithUncheckedException"), started()), event(//
test("testWithUncheckedException"), finishedWithFailure(allOf(//
isA(RuntimeException.class), //
message("unchecked"), //
suppressed(0, allOf(isA(IOException.class), message("checked")))))), //
event(container(FailureTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class ExceptionHandlingTests method uncheckedExceptionInTestMethodIsRegistered.
@Test
void uncheckedExceptionInTestMethodIsRegistered() throws NoSuchMethodException {
Method method = FailureTestCase.class.getDeclaredMethod("testWithUncheckedException");
LauncherDiscoveryRequest request = request().selectors(selectMethod(FailureTestCase.class, method)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getFailedTestFinishedEvents(), event(test("testWithUncheckedException"), finishedWithFailure(allOf(isA(RuntimeException.class), message("unchecked")))));
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class NestedTestClassesTests method nestedTestsAreExecuted.
@Test
void nestedTestsAreExecuted() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithNesting.class);
assertEquals(3, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
assertEquals(3, eventRecorder.getContainerStartedCount(), "# containers started");
assertEquals(3, eventRecorder.getContainerFinishedCount(), "# containers finished");
}
use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.
the class NestedTestClassesTests method doublyNestedTestsAreExecuted.
@Test
void doublyNestedTestsAreExecuted() {
ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithDoubleNesting.class);
assertEquals(5, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(3, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(2, eventRecorder.getTestFailedCount(), "# tests failed");
assertEquals(4, eventRecorder.getContainerStartedCount(), "# containers started");
assertEquals(4, eventRecorder.getContainerFinishedCount(), "# containers finished");
assertAll(//
"before each counts", () -> assertEquals(5, TestCaseWithDoubleNesting.beforeTopCount), () -> assertEquals(4, TestCaseWithDoubleNesting.beforeNestedCount), () -> assertEquals(2, TestCaseWithDoubleNesting.beforeDoublyNestedCount));
assertAll(//
"after each counts", () -> assertEquals(5, TestCaseWithDoubleNesting.afterTopCount), () -> assertEquals(4, TestCaseWithDoubleNesting.afterNestedCount), () -> assertEquals(2, TestCaseWithDoubleNesting.afterDoublyNestedCount));
}
Aggregations