Search in sources :

Example 61 with EngineExecutionResults

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()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) TestInstantiationException(org.junit.jupiter.api.extension.TestInstantiationException) Test(org.junit.jupiter.api.Test)

Example 62 with EngineExecutionResults

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
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 63 with EngineExecutionResults

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()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) TestInstantiationException(org.junit.jupiter.api.extension.TestInstantiationException) Test(org.junit.jupiter.api.Test)

Example 64 with EngineExecutionResults

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()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) ExtensionConfigurationException(org.junit.jupiter.api.extension.ExtensionConfigurationException) Test(org.junit.jupiter.api.Test)

Example 65 with EngineExecutionResults

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);
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) UniqueId(org.junit.platform.engine.UniqueId) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

EngineExecutionResults (org.junit.platform.testkit.engine.EngineExecutionResults)139 Test (org.junit.jupiter.api.Test)134 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)32 DynamicTest (org.junit.jupiter.api.DynamicTest)30 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)30 Events (org.junit.platform.testkit.engine.Events)27 DisplayName (org.junit.jupiter.api.DisplayName)15 RepeatedTest (org.junit.jupiter.api.RepeatedTest)15 IOException (java.io.IOException)12 Execution (org.junit.platform.testkit.engine.Execution)12 TimeoutException (java.util.concurrent.TimeoutException)10 List (java.util.List)8 ExtensionConfigurationException (org.junit.jupiter.api.extension.ExtensionConfigurationException)8 ArrayList (java.util.ArrayList)7 AfterAll (org.junit.jupiter.api.AfterAll)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 Nested (org.junit.jupiter.api.Nested)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7