use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerRethrowsException.
@Test
void exceptionHandlerRethrowsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testRethrow")).build();
EngineExecutionResults executionResults = executeTests(request);
assertTrue(RethrowException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testRethrow"), started()), //
event(test("testRethrow"), finishedWithFailure(instanceOf(IOException.class), message("checked"))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method multipleFactoriesRegisteredOnSingleTestClass.
@Test
void multipleFactoriesRegisteredOnSingleTestClass() {
Class<?> testClass = MultipleFactoriesRegisteredOnSingleTestCase.class;
EngineExecutionResults executionResults = executeTestsForClass(testClass);
assertEquals(0, executionResults.testEvents().started().count(), "# tests started");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests aborted");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(testClass), started()), event(container(testClass), finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message("The following TestInstanceFactory extensions were registered for test class [" + testClass.getName() + "], but only one is permitted: " + //
nullSafeToString(FooInstanceFactory.class, BarInstanceFactory.class)))), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method nullTestInstanceFactoryWithPerMethodLifecycle.
@Test
void nullTestInstanceFactoryWithPerMethodLifecycle() {
Class<?> testClass = NullTestInstanceFactoryTestCase.class;
EngineExecutionResults executionResults = executeTestsForClass(testClass);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().failed().count(), "# tests aborted");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(testClass), started()), //
event(test("testShouldNotBeCalled"), started()), event(test("testShouldNotBeCalled"), finishedWithFailure(instanceOf(TestInstantiationException.class), message(m -> m.equals("TestInstanceFactory [" + NullTestInstanceFactory.class.getName() + "] failed to return an instance of [" + testClass.getName() + //
"] and instead returned an instance of [null].")))), //
event(container(testClass), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method multipleFactoriesRegisteredWithinNestedClassStructure.
@Test
void multipleFactoriesRegisteredWithinNestedClassStructure() {
Class<?> outerClass = MultipleFactoriesRegisteredWithinNestedClassStructureTestCase.class;
Class<?> nestedClass = MultipleFactoriesRegisteredWithinNestedClassStructureTestCase.InnerTestCase.class;
EngineExecutionResults executionResults = executeTestsForClass(outerClass);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(outerClass), started()), //
event(test("outerTest()"), started()), //
event(test("outerTest()"), finishedSuccessfully()), //
event(nestedContainer(nestedClass), started()), event(nestedContainer(nestedClass), finishedWithFailure(instanceOf(ExtensionConfigurationException.class), message("The following TestInstanceFactory extensions were registered for test class [" + nestedClass.getName() + "], but only one is permitted: " + //
nullSafeToString(FooInstanceFactory.class, BarInstanceFactory.class)))), //
event(container(outerClass), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method instanceFactoryRegisteredAsLambdaExpression.
@Test
void instanceFactoryRegisteredAsLambdaExpression() {
EngineExecutionResults executionResults = executeTestsForClass(LambdaFactoryTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly("beforeEach: lambda", "test: lambda");
// @formatter:on
}
Aggregations