use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method singleClassResolution.
@Test
void singleClassResolution() {
ClassSelector selector = selectClass(MyTestClass.class);
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.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method twoClassesResolution.
@Test
void twoClassesResolution() {
ClassSelector selector1 = selectClass(MyTestClass.class);
ClassSelector selector2 = selectClass(YourTestClass.class);
resolver.resolveSelectors(request().selectors(selector1, selector2).build(), engineDescriptor);
assertEquals(7, 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()"));
assertThat(uniqueIds).contains(uniqueIdForClass(YourTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(YourTestClass.class, "test3()"));
assertThat(uniqueIds).contains(uniqueIdForMethod(YourTestClass.class, "test4()"));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingUniqueIdWithUnknownSegmentTypeResolvesNothing.
@Test
@TrackLogRecords
void resolvingUniqueIdWithUnknownSegmentTypeResolvesNothing(LogRecordListener listener) {
UniqueId uniqueId = engineId().append("bogus", "enigma");
UniqueIdSelector selector = selectUniqueId(uniqueId);
EngineDiscoveryRequest request = request().selectors(selector).build();
resolver.resolveSelectors(request, engineDescriptor);
assertTrue(engineDescriptor.getDescendants().isEmpty());
//
assertThat(listener.stream(JavaElementsResolver.class, Level.WARNING).map(LogRecord::getMessage)).contains("Unique ID '" + uniqueId + "' could not be resolved.");
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionByUniqueId.
@Test
void methodResolutionByUniqueId() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(MyTestClass.class, "test1()").toString());
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolution.
@Test
void methodResolution() throws NoSuchMethodException {
Method test1 = MyTestClass.class.getDeclaredMethod("test1");
MethodSelector selector = selectMethod(test1.getDeclaringClass(), test1);
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
}
Aggregations