use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method classLevelExceptionHandlersConvertException.
@Test
void classLevelExceptionHandlersConvertException() {
LauncherDiscoveryRequest request = request().selectors(selectClass(ConvertingTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
assertEquals(1, ConvertExceptionHandler.beforeAllCalls, "Exception should handled in @BeforeAll");
assertEquals(1, ConvertExceptionHandler.afterAllCalls, "Exception should handled in @AfterAll");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(ConvertingTestCase.class), started()), //
event(container(ConvertingTestCase.class), finishedWithFailure(instanceOf(IOException.class))), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class LifecycleMethodExecutionExceptionHandlerTests method multipleHandlersAreCalledInOrder.
@Test
void multipleHandlersAreCalledInOrder() {
LauncherDiscoveryRequest request = request().selectors(selectClass(MultipleHandlersTestCase.class)).build();
EngineExecutionResults executionResults = executeTests(request);
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(MultipleHandlersTestCase.class), started()), //
event(test("aTest"), started()), //
event(test("aTest"), finishedSuccessfully()), //
event(test("aTest2"), started()), //
event(test("aTest2"), finishedSuccessfully()), //
event(container(MultipleHandlersTestCase.class), finishedSuccessfully()), //
event(engine(), finishedSuccessfully()));
assertEquals(Arrays.asList(// BeforeAll chain (class level only)
"RethrowExceptionBeforeAll", "SwallowExceptionBeforeAll", // BeforeEach chain for aTest (test + class level)
"ConvertExceptionBeforeEach", "RethrowExceptionBeforeEach", "SwallowExceptionBeforeEach", // AfterEach chain for aTest (test + class level)
"ConvertExceptionAfterEach", "RethrowExceptionAfterEach", "SwallowExceptionAfterEach", // BeforeEach chain for aTest2 (class level only)
"RethrowExceptionBeforeEach", "SwallowExceptionBeforeEach", // AfterEach chain for aTest2 (class level only)
"RethrowExceptionAfterEach", "SwallowExceptionAfterEach", //
"RethrowExceptionAfterAll", //
"SwallowExceptionAfterAll"), handlerCalls, "Wrong order of handler calls");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method constructorInjectionWithAnnotatedParameter.
@Test
void constructorInjectionWithAnnotatedParameter() {
EngineExecutionResults executionResults = executeTestsForClass(AnnotatedParameterConstructorInjectionTestCase.class);
assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForPrimitiveIntegerMethodInjectionCases.
@Test
void executeTestsForPrimitiveIntegerMethodInjectionCases() {
EngineExecutionResults executionResults = executeTestsForClass(PrimitiveIntegerMethodInjectionTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForMethodInjectionInBeforeAndAfterEachMethods.
@Test
void executeTestsForMethodInjectionInBeforeAndAfterEachMethods() {
EngineExecutionResults executionResults = executeTestsForClass(BeforeAndAfterMethodInjectionTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
Aggregations