use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method doubleNestedTestResolutionFromClass.
@Test
void doubleNestedTestResolutionFromClass() {
ClassSelector selector = selectClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class);
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
List<UniqueId> uniqueIds = uniqueIds();
assertEquals(4, uniqueIds.size());
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, "testC()"));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory.
@Test
@TrackLogRecords
void resolvingDynamicTestByUniqueIdResolvesUpToParentTestFactory(LogRecordListener listener) {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
UniqueId differentDynamicTestUid = factoryUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
resolver.resolveSelectors(request().selectors(selectUniqueId(dynamicTestUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(dynamicTestUid)).isTrue();
assertThat(dynamicDescendantFilter.test(differentDynamicTestUid)).isFalse();
assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingDynamicContainerByUniqueIdResolvesUpToParentTestFactory.
@Test
@TrackLogRecords
void resolvingDynamicContainerByUniqueIdResolvesUpToParentTestFactory(LogRecordListener listener) {
Class<?> clazz = MyTestClass.class;
UniqueId factoryUid = uniqueIdForTestFactoryMethod(clazz, "dynamicTest()");
UniqueId dynamicContainerUid = factoryUid.append(DYNAMIC_CONTAINER_SEGMENT_TYPE, "#1");
UniqueId differentDynamicContainerUid = factoryUid.append(DYNAMIC_CONTAINER_SEGMENT_TYPE, "#2");
UniqueId dynamicTestUid = dynamicContainerUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#1");
UniqueId differentDynamicTestUid = dynamicContainerUid.append(DYNAMIC_TEST_SEGMENT_TYPE, "#2");
resolver.resolveSelectors(request().selectors(selectUniqueId(dynamicTestUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), factoryUid);
TestDescriptor testClassDescriptor = getOnlyElement(engineDescriptor.getChildren());
TestDescriptor testFactoryDescriptor = getOnlyElement(testClassDescriptor.getChildren());
DynamicDescendantFilter dynamicDescendantFilter = getDynamicDescendantFilter(testFactoryDescriptor);
assertThat(dynamicDescendantFilter.test(dynamicTestUid)).isTrue();
assertThat(dynamicDescendantFilter.test(differentDynamicContainerUid)).isFalse();
assertThat(dynamicDescendantFilter.test(differentDynamicTestUid)).isFalse();
assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingTestTemplateInvocationByUniqueIdResolvesOnlyUpToParentTestTemplate.
@Test
void resolvingTestTemplateInvocationByUniqueIdResolvesOnlyUpToParentTestTemplate() {
Class<?> clazz = TestClassWithTemplate.class;
UniqueId templateUid = uniqueIdForTestTemplateMethod(clazz, "testTemplate()");
UniqueId invocationUid = templateUid.append(TestTemplateInvocationTestDescriptor.SEGMENT_TYPE, "#1");
resolver.resolveSelectors(request().selectors(selectUniqueId(invocationUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), templateUid);
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method nestedTestResolutionFromBaseClass.
@Test
void nestedTestResolutionFromBaseClass() {
ClassSelector selector = selectClass(TestCaseWithNesting.class);
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
List<UniqueId> uniqueIds = uniqueIds();
assertEquals(6, uniqueIds.size());
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.class, "testA()"));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.class, "testB()"));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, "testC()"));
}
Aggregations