use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method classResolutionByUniqueId.
@Test
void classResolutionByUniqueId() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForClass(MyTestClass.class).toString());
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(4, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test2()"));
assertThat(uniqueIds).contains(uniqueIdForTestFactoryMethod(MyTestClass.class, "dynamicTest()"));
}
use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionByUniqueIdFromInheritedClass.
@Test
void methodResolutionByUniqueIdFromInheritedClass() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(HerTestClass.class, "test1()").toString());
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(HerTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(HerTestClass.class, "test1()"));
}
use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method nestedTestResolutionFromUniqueIdToMethod.
@Test
void nestedTestResolutionFromUniqueIdToMethod() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.class, "testB()").toString());
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
List<UniqueId> uniqueIds = uniqueIds();
assertEquals(3, uniqueIds.size());
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.class, "testB()"));
}
use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method twoMethodResolutionsByUniqueId.
@Test
void twoMethodResolutionsByUniqueId() {
UniqueIdSelector selector1 = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "test1()").toString());
UniqueIdSelector selector2 = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "test2()").toString());
// adding same selector twice should have no effect
resolver.resolveSelectors(request().selectors(selector1, selector2, selector2).build(), engineDescriptor);
assertEquals(3, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test2()"));
TestDescriptor classFromMethod1 = descriptorByUniqueId(uniqueIdForMethod(MyTestClass.class, "test1()")).getParent().get();
TestDescriptor classFromMethod2 = descriptorByUniqueId(uniqueIdForMethod(MyTestClass.class, "test2()")).getParent().get();
assertEquals(classFromMethod1, classFromMethod2);
assertSame(classFromMethod1, classFromMethod2);
}
Aggregations