use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method inheritedFactoryInTestClassHierarchy.
@Test
void inheritedFactoryInTestClassHierarchy() {
EngineExecutionResults executionResults = executeTestsForClass(InheritedFactoryTestCase.class);
assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly("FooInstanceFactory instantiated: InheritedFactoryTestCase", "parentTest", "FooInstanceFactory instantiated: InheritedFactoryTestCase", "childTest");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method bogusTestInstanceFactoryWithPerMethodLifecycle.
@Test
void bogusTestInstanceFactoryWithPerMethodLifecycle() {
Class<?> testClass = BogusTestInstanceFactoryTestCase.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 [" + BogusTestInstanceFactory.class.getName() + "] failed to return an instance of [" + testClass.getName() + //
"] and instead returned an instance of [java.lang.String].")))), //
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 instanceFactoryWithPerClassLifecycle.
@Test
void instanceFactoryWithPerClassLifecycle() {
EngineExecutionResults executionResults = executeTestsForClass(PerClassLifecycleTestCase.class);
assertEquals(1, PerClassLifecycleTestCase.counter.get());
assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly("FooInstanceFactory instantiated: PerClassLifecycleTestCase", "@BeforeAll", "@BeforeEach", "test1", "@BeforeEach", "test2", "@AfterAll");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method instanceFactoryRegisteredViaTestInterface.
@Test
void instanceFactoryRegisteredViaTestInterface() {
EngineExecutionResults executionResults = executeTestsForClass(FactoryFromInterfaceTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly("FooInstanceFactory instantiated: FactoryFromInterfaceTestCase", "test");
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestInstanceFactoryTests method instanceFactoriesInNestedClassStructureAreInherited.
@Test
void instanceFactoriesInNestedClassStructureAreInherited() {
EngineExecutionResults executionResults = executeTestsForClass(OuterTestCase.class);
assertEquals(3, executionResults.testEvents().started().count(), "# tests started");
assertEquals(3, executionResults.testEvents().succeeded().count(), "# tests succeeded");
// @formatter:off
assertThat(callSequence).containsExactly(// OuterTestCase
"FooInstanceFactory instantiated: OuterTestCase", "outerTest", // InnerTestCase
"FooInstanceFactory instantiated: OuterTestCase", "FooInstanceFactory instantiated: InnerTestCase", "innerTest1", // InnerInnerTestCase
"FooInstanceFactory instantiated: OuterTestCase", "FooInstanceFactory instantiated: InnerTestCase", "FooInstanceFactory instantiated: InnerInnerTestCase", "innerTest2");
// @formatter:on
}
Aggregations