use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodOfInnerClassByUniqueId.
@Test
void methodOfInnerClassByUniqueId() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()").toString());
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(OtherTestClass.NestedTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(OtherTestClass.NestedTestClass.class, "test5()"));
}
use of org.junit.platform.engine.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionByUniqueIdWithMissingMethodName.
@Test
void methodResolutionByUniqueIdWithMissingMethodName() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(getClass(), "()"));
assertMethodDoesNotMatchPattern(selector);
}
use of org.junit.platform.engine.discovery.UniqueIdSelector 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.discovery.UniqueIdSelector 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.discovery.UniqueIdSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionByUniqueIdWithBogusParameters.
@Test
void methodResolutionByUniqueIdWithBogusParameters() {
UniqueIdSelector selector = selectUniqueId(uniqueIdForMethod(getClass(), "methodName(java.lang.String, junit.foo.Enigma)"));
Exception exception = assertThrows(JUnitException.class, () -> resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor));
assertThat(exception).hasMessageStartingWith("Failed to load parameter type");
assertThat(exception).hasMessageContaining("junit.foo.Enigma");
}
Aggregations