use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method nestedTestResolutionFromUniqueId.
@Test
void nestedTestResolutionFromUniqueId() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class).toString());
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 methodResolutionByUniqueIdWithParams.
@Test
@TrackLogRecords
void methodResolutionByUniqueIdWithParams(LogRecordListener listener) {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(HerTestClass.class, "test7(java.lang.String)").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, "test7(java.lang.String)"));
assertThat(listener.stream(JavaElementsResolver.class)).isEmpty();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionFromInheritedMethod.
@Test
void methodResolutionFromInheritedMethod() throws NoSuchMethodException {
MethodSelector selector = selectMethod(HerTestClass.class, MyTestClass.class.getDeclaredMethod("test1"));
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 classpathResolution.
@Test
void classpathResolution() throws Exception {
Path classpath = Paths.get(DiscoverySelectorResolverTests.class.getProtectionDomain().getCodeSource().getLocation().toURI());
List<ClasspathRootSelector> selectors = selectClasspathRoots(singleton(classpath));
resolver.resolveSelectors(request().selectors(selectors).build(), engineDescriptor);
// 150 is completely arbitrary. The actual number is likely much higher.
//
assertThat(engineDescriptor.getDescendants().size()).describedAs(//
"Too few test descriptors in classpath").isGreaterThan(150);
List<UniqueId> uniqueIds = uniqueIds();
//
assertThat(uniqueIds).describedAs(//
"Failed to pick up DefaultPackageTestCase via classpath scanning").contains(uniqueIdForClass(ReflectionUtils.loadClass("DefaultPackageTestCase").get()));
assertThat(uniqueIds).contains(uniqueIdForClass(Class1WithTestCases.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(Class1WithTestCases.class, "test1()"));
assertThat(uniqueIds).contains(uniqueIdForClass(Class2WithTestCases.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(Class2WithTestCases.class, "test2()"));
assertThat(uniqueIds).contains(uniqueIdForMethod(ClassWithStaticInnerTestCases.ShouldBeDiscovered.class, "test1()"));
}
use of org.junit.platform.engine.UniqueId 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()"));
}
Aggregations