Search in sources :

Example 31 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class DynamicNodeGenerationTests method singleDynamicTestInNestedDynamicContainerIsExecutedWhenDiscoveredByUniqueId.

@Test
void singleDynamicTestInNestedDynamicContainerIsExecutedWhenDiscoveredByUniqueId() {
    UniqueId uniqueId = // 
    discoverUniqueId(MyDynamicTestCase.class, "twoNestedContainersWithTwoTestsEach").append(DYNAMIC_CONTAINER_SEGMENT_TYPE, // 
    "#1").append(DYNAMIC_CONTAINER_SEGMENT_TYPE, // 
    "#1").append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
    EngineExecutionResults executionResults = executeTests(selectUniqueId(uniqueId));
    // 
    executionResults.allEvents().assertEventsMatchExactly(// 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("twoNestedContainersWithTwoTestsEach"), started()), // 
    event(dynamicTestRegistered(displayName("a"))), // 
    event(container(displayName("a")), started()), // 
    event(dynamicTestRegistered(displayName("a1"))), // 
    event(container(displayName("a1")), started()), // 
    event(dynamicTestRegistered("dynamic-test:#2")), // 
    event(test("dynamic-test:#2", "failingTest"), started()), // 
    event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // 
    event(container(displayName("a1")), finishedSuccessfully()), // 
    event(container(displayName("a")), finishedSuccessfully()), // 
    event(container("twoNestedContainersWithTwoTestsEach"), finishedSuccessfully()), // 
    event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 32 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class NestedTestClassesTests method extendedNestedTestsAreExecuted.

@Test
void extendedNestedTestsAreExecuted() {
    EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithExtendedNested.class);
    executionResults.allEvents().debug();
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(6, tests.started().count(), "# tests started");
    assertEquals(4, tests.succeeded().count(), "# tests succeeded");
    assertEquals(2, tests.failed().count(), "# tests failed");
    assertEquals(8, containers.started().count(), "# containers started");
    assertEquals(8, containers.finished().count(), "# containers finished");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 33 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class NestedTestClassesTests method doublyNestedTestsAreExecuted.

@Test
void doublyNestedTestsAreExecuted() {
    EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithDoubleNesting.class);
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(5, tests.started().count(), "# tests started");
    assertEquals(3, tests.succeeded().count(), "# tests succeeded");
    assertEquals(2, tests.failed().count(), "# tests failed");
    assertEquals(4, containers.started().count(), "# containers started");
    assertEquals(4, containers.finished().count(), "# containers finished");
    assertAll(// 
    "before each counts", () -> assertEquals(5, TestCaseWithDoubleNesting.beforeTopCount), () -> assertEquals(4, TestCaseWithDoubleNesting.beforeNestedCount), () -> assertEquals(2, TestCaseWithDoubleNesting.beforeDoublyNestedCount));
    assertAll(// 
    "after each counts", () -> assertEquals(5, TestCaseWithDoubleNesting.afterTopCount), () -> assertEquals(4, TestCaseWithDoubleNesting.afterNestedCount), () -> assertEquals(2, TestCaseWithDoubleNesting.afterDoublyNestedCount));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 34 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class NestedTestClassesTests method nestedTestsAreExecuted.

@Test
void nestedTestsAreExecuted() {
    EngineExecutionResults executionResults = executeTestsForClass(TestCaseWithNesting.class);
    Events containers = executionResults.containerEvents();
    Events tests = executionResults.testEvents();
    assertEquals(3, tests.started().count(), "# tests started");
    assertEquals(2, tests.succeeded().count(), "# tests succeeded");
    assertEquals(1, tests.failed().count(), "# tests failed");
    assertEquals(3, containers.started().count(), "# containers started");
    assertEquals(3, containers.finished().count(), "# containers finished");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Events(org.junit.platform.testkit.engine.Events) Test(org.junit.jupiter.api.Test)

Example 35 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestClassInheritanceTests method executeSingleTest.

@Test
void executeSingleTest() {
    EngineExecutionResults executionResults = executeTests(selectMethod(LocalTestCase.class, "alwaysPasses"));
    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");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) 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