use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ExceptionHandlingTests method checkedExceptionInAfterEachIsSuppressedByExceptionInTest.
@Test
void checkedExceptionInAfterEachIsSuppressedByExceptionInTest() {
Class<?> testClass = FailureTestCase.class;
FailureTestCase.exceptionToThrowInAfterEach = Optional.of(new IOException("checked"));
EngineExecutionResults executionResults = executeTests(selectMethod(testClass, "testWithUncheckedException"));
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(testClass), started()), //
event(test("testWithUncheckedException"), started()), event(//
test("testWithUncheckedException"), finishedWithFailure(//
instanceOf(RuntimeException.class), //
message("unchecked"), //
suppressed(0, instanceOf(IOException.class), message("checked")))), //
event(container(testClass), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ExceptionHandlingTests method uncheckedExceptionInTestMethodIsRegistered.
@Test
void uncheckedExceptionInTestMethodIsRegistered() {
EngineExecutionResults executionResults = executeTests(selectMethod(FailureTestCase.class, "testWithUncheckedException"));
Events tests = executionResults.testEvents();
tests.assertStatistics(stats -> stats.started(1).failed(1));
//
tests.failed().assertEventsMatchExactly(event(test("testWithUncheckedException"), finishedWithFailure(instanceOf(RuntimeException.class), message("unchecked"))));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DynamicNodeGenerationTests method singleDynamicTestIsExecutedWhenDiscoveredByIterationIndex.
@Test
void singleDynamicTestIsExecutedWhenDiscoveredByIterationIndex() {
var methodSelector = selectMethod(MyDynamicTestCase.class, "dynamicStream");
EngineExecutionResults executionResults = executeTests(selectIteration(methodSelector, 1));
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("dynamicStream"), started()), //
event(dynamicTestRegistered("dynamic-test:#2")), //
event(test("dynamic-test:#2", "failingTest"), started()), //
event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), //
event(container("dynamicStream"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DynamicNodeGenerationTests method dynamicContainersAreExecutedFromIterable.
@Test
void dynamicContainersAreExecutedFromIterable() {
EngineExecutionResults executionResults = executeTests(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithIterable"));
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("dynamicContainerWithIterable"), 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"), finishedSuccessfully()), //
event(container("dynamicContainerWithIterable"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
Events containers = executionResults.containerEvents();
Events tests = executionResults.testEvents();
assertAll(() -> assertEquals(4, containers.started().count(), "# container started"), () -> assertEquals(1, containers.dynamicallyRegistered().count(), "# dynamic containers registered"), () -> assertEquals(2, tests.dynamicallyRegistered().count(), "# dynamic tests registered"), () -> assertEquals(2, tests.started().count(), "# tests started"), () -> assertEquals(1, tests.succeeded().count(), "# tests succeeded"), () -> assertEquals(1, tests.failed().count(), "# tests failed"), () -> assertEquals(4, containers.finished().count(), "# container finished"));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class DynamicNodeGenerationTests method nestedDynamicContainersAreExecuted.
@Test
void nestedDynamicContainersAreExecuted() {
EngineExecutionResults executionResults = executeTests(selectMethod(MyDynamicTestCase.class, "nestedDynamicContainers"));
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(MyDynamicTestCase.class), started()), //
event(container("nestedDynamicContainers"), started()), //
event(dynamicTestRegistered(displayName("gift wrap"))), //
event(container(displayName("gift wrap")), started()), //
event(dynamicTestRegistered(displayName("box"))), //
event(container(displayName("box")), 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(displayName("box")), finishedSuccessfully()), //
event(container(displayName("gift wrap")), finishedSuccessfully()), //
event(container("nestedDynamicContainers"), finishedSuccessfully()), //
event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
Events containers = executionResults.containerEvents();
Events tests = executionResults.testEvents();
assertAll(() -> assertEquals(5, containers.started().count(), "# container started"), () -> assertEquals(2, containers.dynamicallyRegistered().count(), "# dynamic containers registered"), () -> assertEquals(2, tests.dynamicallyRegistered().count(), "# dynamic tests registered"), () -> assertEquals(2, tests.started().count(), "# tests started"), () -> assertEquals(1, tests.succeeded().count(), "# tests succeeded"), () -> assertEquals(1, tests.failed().count(), "# tests failed"), () -> assertEquals(5, containers.finished().count(), "# container finished"));
}
Aggregations