use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method testTemplateMethodResolutionByUniqueId.
@Test
void testTemplateMethodResolutionByUniqueId() {
Class<?> clazz = TestClassWithTemplate.class;
UniqueId templateUid = uniqueIdForTestTemplateMethod(clazz, "testTemplate()");
resolver.resolveSelectors(request().selectors(selectUniqueId(templateUid)).build(), engineDescriptor);
assertThat(engineDescriptor.getDescendants()).hasSize(2);
assertThat(uniqueIds()).containsSequence(uniqueIdForClass(clazz), templateUid);
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestMethodFilterTests method newTestMethodDescriptor.
private static TestMethodTestDescriptor newTestMethodDescriptor() throws Exception {
UniqueId uniqueId = UniqueId.forEngine("method");
Class<TestClass> testClass = TestClass.class;
Method testMethod = testClass.getMethod("testMethod");
return new TestMethodTestDescriptor(uniqueId, testClass, testMethod);
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestEngineSpy method discover.
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
this.discoveryRequestForDiscovery = discoveryRequest;
this.uniqueIdForDiscovery = uniqueId;
UniqueId engineUniqueId = UniqueId.forEngine(ID);
TestDescriptorStub engineDescriptor = new TestDescriptorStub(engineUniqueId, ID);
TestDescriptorStub testDescriptor = new TestDescriptorStub(engineUniqueId.append("test", "test"), "test");
engineDescriptor.addChild(testDescriptor);
return engineDescriptor;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestClassWithTemplate method packageResolutionUsingExplicitBasePackage.
@Test
void packageResolutionUsingExplicitBasePackage() {
PackageSelector selector = selectPackage("org.junit.jupiter.engine.descriptor.subpackage");
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(6, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
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 resolvingUniqueIdWithWrongParamsResolvesNothing.
@Test
@TrackLogRecords
void resolvingUniqueIdWithWrongParamsResolvesNothing(LogRecordListener listener) {
UniqueId uniqueId = uniqueIdForMethod(HerTestClass.class, "test7(java.math.BigDecimal)");
EngineDiscoveryRequest request = request().selectors(selectUniqueId(uniqueId)).build();
resolver.resolveSelectors(request, engineDescriptor);
assertTrue(engineDescriptor.getDescendants().isEmpty());
//
assertThat(listener.stream(JavaElementsResolver.class, Level.WARNING).map(LogRecord::getMessage)).contains("Unique ID '" + uniqueId + "' could only be partially resolved. " + "All resolved segments will be executed; however, the following segments " + "could not be resolved: [Segment [type = 'method', value = 'test7(java.math.BigDecimal)']]");
}
Aggregations