use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method nestedTestResolutionFromNestedTestClass.
@Test
void nestedTestResolutionFromNestedTestClass() {
ClassSelector selector = selectClass(TestCaseWithNesting.NestedTestCase.class);
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
List<UniqueId> uniqueIds = uniqueIds();
assertEquals(5, uniqueIds.size());
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
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()"));
}
use of org.junit.platform.engine.UniqueId 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.UniqueId 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.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionInDoubleNestedTestClass.
@Test
void methodResolutionInDoubleNestedTestClass() throws NoSuchMethodException {
MethodSelector selector = selectMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class.getDeclaredMethod("testC"));
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(4, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
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 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