Search in sources :

Example 21 with UniqueId

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

the class TestClassWithTemplate method classResolutionOfStaticNestedClass.

@Test
void classResolutionOfStaticNestedClass() {
    ClassSelector selector = selectClass(OtherTestClass.NestedTestClass.class);
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(3, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test6()"));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ClassSelector(org.junit.platform.engine.discovery.ClassSelector) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 22 with UniqueId

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

the class TestClassWithTemplate method staticNestedClassResolutionByUniqueId.

@Test
void staticNestedClassResolutionByUniqueId() {
    UniqueIdSelector selector = selectUniqueId(uniqueIdForClass(OtherTestClass.NestedTestClass.class).toString());
    resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
    assertEquals(3, engineDescriptor.getDescendants().size());
    List<UniqueId> uniqueIds = uniqueIds();
    assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
    assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test6()"));
}
Also used : UniqueIdSelector(org.junit.platform.engine.discovery.UniqueIdSelector) DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 23 with UniqueId

use of org.junit.platform.engine.UniqueId 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 24 with UniqueId

use of org.junit.platform.engine.UniqueId 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)

Example 25 with UniqueId

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

the class TestTemplateInvocationTests method singleInvocationIsExecutedWhenDiscoveredByUniqueId.

@Test
void singleInvocationIsExecutedWhenDiscoveredByUniqueId() {
    UniqueId uniqueId = discoverUniqueId(MyTestTemplateTestCase.class, // 
    "templateWithTwoInvocationsFromSingleExtension").append(TestTemplateInvocationTestDescriptor.SEGMENT_TYPE, "#2");
    ExecutionEventRecorder eventRecorder = executeTests(selectUniqueId(uniqueId));
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getExecutionEvents(), wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithTwoInvocationsFromSingleExtension"), started()), // 
    event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), // 
    event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), // 
    finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
Also used : DiscoverySelectors.selectUniqueId(org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId) UniqueId(org.junit.platform.engine.UniqueId) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Aggregations

UniqueId (org.junit.platform.engine.UniqueId)78 Test (org.junit.jupiter.api.Test)59 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)44 DynamicTest (org.junit.jupiter.api.DynamicTest)32 TestDescriptor (org.junit.platform.engine.TestDescriptor)19 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)13 UniqueIdSelector (org.junit.platform.engine.discovery.UniqueIdSelector)12 TestPlan (org.junit.platform.launcher.TestPlan)10 ClassSelector (org.junit.platform.engine.discovery.ClassSelector)8 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)7 List (java.util.List)5 TrackLogRecords (org.junit.jupiter.engine.TrackLogRecords)5 ClassTestDescriptor (org.junit.jupiter.engine.descriptor.ClassTestDescriptor)5 Method (java.lang.reflect.Method)4 ArrayList (java.util.ArrayList)4 JupiterTestDescriptor (org.junit.jupiter.engine.descriptor.JupiterTestDescriptor)4 TestTemplateInvocationTestDescriptor (org.junit.jupiter.engine.descriptor.TestTemplateInvocationTestDescriptor)4 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)4 ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)4 Optional (java.util.Optional)3