Search in sources :

Example 36 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class DynamicNodeGenerationTests method dynamicContainersChildrenMustNotBeNull.

@Test
void dynamicContainersChildrenMustNotBeNull() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithNullChildren")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("dynamicContainerWithNullChildren"), started()), // 
    event(dynamicTestRegistered("dynamic-container:#1")), // 
    event(container("dynamic-container:#1"), started()), event(// 
    container("dynamic-container:#1"), // 
    finishedWithFailure(message("individual dynamic node must not be null"))), // 
    event(container("dynamicContainerWithNullChildren"), 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 37 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class DynamicNodeGenerationTests method dynamicContainersAreExecutedFromExceptionThrowingStream.

@Test
void dynamicContainersAreExecutedFromExceptionThrowingStream() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicContainerWithExceptionThrowingStream")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertTrue(MyDynamicTestCase.exceptionThrowingStreamClosed.get(), "stream should be closed");
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), // 
    event(engine(), started()), // 
    event(container(MyDynamicTestCase.class), started()), // 
    event(container("dynamicContainerWithExceptionThrowingStream"), 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"), finishedWithFailure(isA(ArrayIndexOutOfBoundsException.class))), // 
    event(container("dynamicContainerWithExceptionThrowingStream"), 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 38 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class DynamicNodeGenerationTests method legacyReportingNames.

@Test
void legacyReportingNames() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "nestedDynamicContainers")).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    // @formatter:off
    Stream<String> legacyReportingNames = eventRecorder.getExecutionEvents().stream().filter(event -> event.getType() == DYNAMIC_TEST_REGISTERED).map(ExecutionEvent::getTestDescriptor).map(TestDescriptor::getLegacyReportingName);
    // @formatter:off
    assertThat(legacyReportingNames).containsExactly("nestedDynamicContainers()[1]", "nestedDynamicContainers()[1][1]", "nestedDynamicContainers()[1][1][1]", "nestedDynamicContainers()[1][1][2]");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) TestDescriptor(org.junit.platform.engine.TestDescriptor) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 39 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class DynamicNodeGenerationTests method testFactoryMethodsAreCorrectlyDiscoveredForClassSelector.

@Test
void testFactoryMethodsAreCorrectlyDiscoveredForClassSelector() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(MyDynamicTestCase.class)).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertThat(engineDescriptor.getDescendants()).as("# resolved test descriptors").hasSize(10);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 40 with LauncherDiscoveryRequest

use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.

the class DynamicNodeGenerationTests method testFactoryMethodIsCorrectlyDiscoveredForMethodSelector.

@Test
void testFactoryMethodIsCorrectlyDiscoveredForMethodSelector() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyDynamicTestCase.class, "dynamicStream")).build();
    TestDescriptor engineDescriptor = discoverTests(request);
    assertThat(engineDescriptor.getDescendants()).as("# resolved test descriptors").hasSize(2);
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Aggregations

LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)167 Test (org.junit.jupiter.api.Test)141 ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)74 TestDescriptor (org.junit.platform.engine.TestDescriptor)54 PlainOldJavaClassWithoutAnyTest (org.junit.vintage.engine.samples.PlainOldJavaClassWithoutAnyTest)33 Launcher (org.junit.platform.launcher.Launcher)16 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)11 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)11 PlainJUnit4TestCaseWithFiveTestMethods (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithFiveTestMethods)11 Method (java.lang.reflect.Method)10 PlainJUnit4TestCaseWithSingleTestWhichFails (org.junit.vintage.engine.samples.junit4.PlainJUnit4TestCaseWithSingleTestWhichFails)8 IOException (java.io.IOException)7 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)7 ArrayList (java.util.ArrayList)6 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)6 TestIdentifier (org.junit.platform.launcher.TestIdentifier)5 TestPlan (org.junit.platform.launcher.TestPlan)5 Path (java.nio.file.Path)4 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)4