use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method explosiveTestInstanceFactoryWithPerClassLifecycle.
@Test
void explosiveTestInstanceFactoryWithPerClassLifecycle() {
Class<?> testClass = PerClassLifecycleExplosiveTestInstanceFactoryTestCase.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(TestInstantiationException.class), message("TestInstanceFactory [" + ExplosiveTestInstanceFactory.class.getName() + "] failed to instantiate test class [" + testClass.getName() + //
"]: boom!"))), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method instanceFactoryOnTopLevelTestClass.
@Test
void instanceFactoryOnTopLevelTestClass() {
EngineExecutionResults executionResults = executeTestsForClass(ParentTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly("FooInstanceFactory instantiated: ParentTestCase", "parentTest");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method explosiveTestInstanceFactoryWithPerMethodLifecycle.
@Test
void explosiveTestInstanceFactoryWithPerMethodLifecycle() {
Class<?> testClass = ExplosiveTestInstanceFactoryTestCase.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("TestInstanceFactory [" + ExplosiveTestInstanceFactory.class.getName() + "] failed to instantiate test class [" + testClass.getName() + //
"]: boom!"))), //
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 multipleFactoriesRegisteredWithinTestClassHierarchy.
@Test
void multipleFactoriesRegisteredWithinTestClassHierarchy() {
Class<?> testClass = MultipleFactoriesRegisteredWithinClassHierarchyTestCase.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 UniqueIdParsingForArrayParameterIntegrationTests method executeTestsForPrimitiveArrayMethodInjectionCases.
@Test
void executeTestsForPrimitiveArrayMethodInjectionCases() {
EngineExecutionResults executionResults = executeTestsForClass(PrimitiveArrayMethodInjectionTestCase.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");
// @formatter:off
UniqueId uniqueId = executionResults.allEvents().map(Event::getTestDescriptor).distinct().skip(2).map(TestDescriptor::getUniqueId).findFirst().orElseThrow(AssertionError::new);
// @formatter:on
assertThat(UniqueId.parse(uniqueId.toString())).isEqualTo(uniqueId);
}
Aggregations