Search in sources :

Example 31 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class DynamicNodeGenerationTests method dynamicContainersAreExecutedFromIterable.

@Test
void dynamicContainersAreExecutedFromIterable() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithIterable")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("dynamicContainerWithIterable"), started()), // 
    event(dynamicTestRegistered("dynamic-container:#1")), // 
    event(container("dynamic-container:#1"), started()), // 
    event(dynamicTestRegistered("dynamic-test:#1")), // 
    event(test("dynamic-test:#1", "succeedingTest"), started()), // 
    event(test("dynamic-test:#1", "succeedingTest"), finishedSuccessfully()), // 
    event(dynamicTestRegistered("dynamic-test:#2")), // 
    event(test("dynamic-test:#2", "failingTest"), started()), // 
    event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // 
    event(container("dynamic-container:#1"), finishedSuccessfully()), // 
    event(container("dynamicContainerWithIterable"), finishedSuccessfully()), // 
    event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
    assertAll(() -> assertEquals(4, eventRecorder.getContainerStartedCount(), "# container started"), () -> assertEquals(3, eventRecorder.getDynamicTestRegisteredCount(), "# dynamic tests registered"), () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed"), () -> assertEquals(4, eventRecorder.getContainerFinishedCount(), "# container finished"));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 32 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class DynamicNodeGenerationTests method nestedDynamicContainersAreExecuted.

@Test
void nestedDynamicContainersAreExecuted() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "nestedDynamicContainers")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("nestedDynamicContainers"), started()), // 
    event(dynamicTestRegistered(displayName("gift wrap"))), // 
    event(container(displayName("gift wrap")), started()), // 
    event(dynamicTestRegistered(displayName("box"))), // 
    event(container(displayName("box")), started()), // 
    event(dynamicTestRegistered("dynamic-test:#1")), // 
    event(test("dynamic-test:#1", "succeedingTest"), started()), // 
    event(test("dynamic-test:#1", "succeedingTest"), finishedSuccessfully()), // 
    event(dynamicTestRegistered("dynamic-test:#2")), // 
    event(test("dynamic-test:#2", "failingTest"), started()), // 
    event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // 
    event(container(displayName("box")), finishedSuccessfully()), // 
    event(container(displayName("gift wrap")), finishedSuccessfully()), // 
    event(container("nestedDynamicContainers"), finishedSuccessfully()), // 
    event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
    assertAll(() -> assertEquals(5, eventRecorder.getContainerStartedCount(), "# container started"), () -> assertEquals(4, eventRecorder.getDynamicTestRegisteredCount(), "# dynamic tests registered"), () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed"), () -> assertEquals(5, eventRecorder.getContainerFinishedCount(), "# container finished"));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 33 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class DynamicNodeGenerationTests method dynamicTestsAreExecutedFromStream.

@Test
void dynamicTestsAreExecutedFromStream() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicStream")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("dynamicStream"), started()), // 
    event(dynamicTestRegistered("dynamic-test:#1")), // 
    event(test("dynamic-test:#1", "succeedingTest"), started()), // 
    event(test("dynamic-test:#1", "succeedingTest"), finishedSuccessfully()), // 
    event(dynamicTestRegistered("dynamic-test:#2")), // 
    event(test("dynamic-test:#2", "failingTest"), started()), // 
    event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // 
    event(container("dynamicStream"), finishedSuccessfully()), // 
    event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 34 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class DynamicNodeGenerationTests method singleDynamicTestIsExecutedWhenDiscoveredByUniqueId.

@Test
void singleDynamicTestIsExecutedWhenDiscoveredByUniqueId() {
    UniqueId uniqueId = // 
    discoverUniqueId(MyDynamicTestCase.class, "dynamicStream").append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
    ExecutionEventRecorder eventRecorder = executeTests(selectUniqueId(uniqueId));
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("dynamicStream"), started()), // 
    event(dynamicTestRegistered("dynamic-test:#2")), // 
    event(test("dynamic-test:#2", "failingTest"), started()), // 
    event(test("dynamic-test:#2", "failingTest"), finishedWithFailure(message("failing"))), // 
    event(container("dynamicStream"), finishedSuccessfully()), // 
    event(container(MyDynamicTestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 35 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder 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");
    ExecutionEventRecorder eventRecorder = executeTests(selectUniqueId(uniqueId));
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    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 : UniqueId(org.junit.platform.engine.UniqueId) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)114 Test (org.junit.jupiter.api.Test)104 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)74 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)12 Method (java.lang.reflect.Method)10 TestDescriptor (org.junit.platform.engine.TestDescriptor)8 IOException (java.io.IOException)6 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 TestInfo (org.junit.jupiter.api.TestInfo)4 UniqueId (org.junit.platform.engine.UniqueId)4 JupiterTestEngine (org.junit.jupiter.engine.JupiterTestEngine)3 LauncherDiscoveryRequestBuilder.request (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request)3 Map (java.util.Map)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 Assertions.allOf (org.assertj.core.api.Assertions.allOf)2