use of org.junit.platform.engine.EngineDiscoveryRequest in project junit5 by junit-team.
the class DefaultLauncherTests method prunesTestDescriptorsAfterApplyingPostDiscoveryFilters.
@Test
void prunesTestDescriptorsAfterApplyingPostDiscoveryFilters() {
TestEngineSpy engine = new TestEngineSpy() {
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
super.discover(discoveryRequest, uniqueId);
TestDescriptorStub engineDescriptor = new TestDescriptorStub(uniqueId, uniqueId.toString());
TestDescriptorStub containerDescriptor = new TestDescriptorStub(uniqueId.append("container", "a"), "container") {
@Override
public Type getType() {
return Type.CONTAINER;
}
};
containerDescriptor.addChild(new TestDescriptorStub(containerDescriptor.getUniqueId().append("test", "b"), "test"));
engineDescriptor.addChild(containerDescriptor);
return engineDescriptor;
}
};
DefaultLauncher launcher = createLauncher(engine);
TestPlan testPlan = launcher.discover(request().filters((PostDiscoveryFilter) testDescriptor -> FilterResult.includedIf(testDescriptor.isContainer())).build());
assertThat(testPlan.getRoots()).hasSize(1);
TestIdentifier engineIdentifier = getOnlyElement(testPlan.getRoots());
assertThat(testPlan.getChildren(engineIdentifier)).isEmpty();
}
use of org.junit.platform.engine.EngineDiscoveryRequest 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)']]");
}
use of org.junit.platform.engine.EngineDiscoveryRequest 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.EngineDiscoveryRequest in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingSelectorOfNonTestMethodResolvesNothing.
@Test
void resolvingSelectorOfNonTestMethodResolvesNothing() throws NoSuchMethodException {
Method notATest = MyTestClass.class.getDeclaredMethod("notATest");
MethodSelector selector = selectMethod(notATest.getDeclaringClass(), notATest);
EngineDiscoveryRequest request = request().selectors(selector).build();
resolver.resolveSelectors(request, engineDescriptor);
assertTrue(engineDescriptor.getDescendants().isEmpty());
}
use of org.junit.platform.engine.EngineDiscoveryRequest in project junit5 by junit-team.
the class UniqueIdSelectorResolverTests method logsWarningOnUnexpectedTestDescriptor.
@Test
void logsWarningOnUnexpectedTestDescriptor(LogRecordListener listener) {
UniqueId uniqueId = UniqueId.forEngine(ENGINE_ID).append("wrong-type", "foo:bar");
EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
assertNoRequests();
assertLoggedWarning(listener, "Unresolvable Unique ID (" + uniqueId + "): Unique ID segment after engine segment must be of type \"runner\"");
}
Aggregations