use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method classLevelExceptionHandlersRethrowException.
@Test
void classLevelExceptionHandlersRethrowException() {
LauncherDiscoveryRequest request = request().selectors(selectClass(RethrowingTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(1, RethrowExceptionHandler.beforeAllCalls, "Exception should handled in @BeforeAll");
assertEquals(1, RethrowExceptionHandler.afterAllCalls, "Exception should handled in @AfterAll");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(RethrowingTestCase.class), started()), //
event(container(RethrowingTestCase.class), finishedWithFailure(instanceOf(RuntimeException.class))), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method exceptionHandlersSwallowException.
@Test
void exceptionHandlersSwallowException() {
LauncherDiscoveryRequest request = request().selectors(selectClass(SwallowingTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(1, SwallowExceptionHandler.beforeAllCalls, "Exception should be handled in @BeforeAll");
assertEquals(1, SwallowExceptionHandler.beforeEachCalls, "Exception should be handled in @BeforeEach");
assertEquals(1, SwallowExceptionHandler.afterEachCalls, "Exception should be handled in @AfterEach");
assertEquals(1, SwallowExceptionHandler.afterAllCalls, "Exception should be handled in @AfterAll");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(SwallowingTestCase.class), started()), //
event(test("aTest"), started()), //
event(test("aTest"), finishedSuccessfully()), //
event(container(SwallowingTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method testLevelExceptionHandlersConvertException.
@Test
void testLevelExceptionHandlersConvertException() {
throwExceptionBeforeAll = false;
throwExceptionAfterAll = false;
LauncherDiscoveryRequest request = request().selectors(selectClass(ConvertingTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(1, ConvertExceptionHandler.beforeEachCalls, "Exception should be handled in @BeforeEach");
assertEquals(1, ConvertExceptionHandler.afterEachCalls, "Exception should be handled in @AfterEach");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(ConvertingTestCase.class), started()), //
event(test("aTest"), started()), //
event(test("aTest"), finishedWithFailure(instanceOf(IOException.class))), //
event(container(ConvertingTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method testLevelExceptionHandlersRethrowException.
@Test
void testLevelExceptionHandlersRethrowException() {
throwExceptionBeforeAll = false;
throwExceptionAfterAll = false;
LauncherDiscoveryRequest request = request().selectors(selectClass(RethrowingTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(1, RethrowExceptionHandler.beforeEachCalls, "Exception should be handled in @BeforeEach");
assertEquals(1, RethrowExceptionHandler.afterEachCalls, "Exception should be handled in @AfterEach");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(RethrowingTestCase.class), started()), //
event(test("aTest"), started()), //
event(test("aTest"), finishedWithFailure(instanceOf(RuntimeException.class))), //
event(container(RethrowingTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method perClassLifecycleMethodsAreHandled.
@Test
void perClassLifecycleMethodsAreHandled() {
LauncherDiscoveryRequest request = request().selectors(selectClass(PerClassLifecycleTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(2, SwallowExceptionHandler.beforeAllCalls, "Exception should be handled in @BeforeAll");
assertEquals(1, SwallowExceptionHandler.beforeEachCalls, "Exception should be handled in @BeforeEach");
assertEquals(1, SwallowExceptionHandler.afterEachCalls, "Exception should be handled in @AfterEach");
assertEquals(2, SwallowExceptionHandler.afterAllCalls, "Exception should be handled in @AfterAll");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(PerClassLifecycleTestCase.class), started()), //
event(test("aTest"), started()), //
event(test("aTest"), finishedSuccessfully()), //
event(container(PerClassLifecycleTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Aggregations