use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class EngineDiscoveryRequestResolution method resolveCompletely.
private void resolveCompletely(DiscoverySelector selector) {
EngineDiscoveryListener discoveryListener = request.getDiscoveryListener();
UniqueId engineId = engineDescriptor.getUniqueId();
try {
Optional<Resolution> result = resolve(selector);
if (result.isPresent()) {
discoveryListener.selectorProcessed(engineId, selector, resolved());
enqueueAdditionalSelectors(result.get());
} else {
discoveryListener.selectorProcessed(engineId, selector, unresolved());
}
} catch (Throwable t) {
UnrecoverableExceptions.rethrowIfUnrecoverable(t);
discoveryListener.selectorProcessed(engineId, selector, failed(t));
}
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class RunListenerAdapter method registerDynamicTestDescriptor.
private VintageTestDescriptor registerDynamicTestDescriptor(Description description, Function<Description, Optional<VintageTestDescriptor>> lookup) {
// workaround for dynamic children as used by Spock's Runner
TestDescriptor parent = findParent(description, lookup);
UniqueId uniqueId = parent.getUniqueId().append(SEGMENT_TYPE_DYNAMIC, uniqueIdExtractor.apply(description));
VintageTestDescriptor dynamicDescriptor = new VintageTestDescriptor(uniqueId, description, testSourceProvider.findTestSource(description));
parent.addChild(dynamicDescriptor);
testRun.registerDynamicTest(dynamicDescriptor);
dynamicTestRegistered(dynamicDescriptor);
return dynamicDescriptor;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class RunnerTestDescriptorPostProcessor method addChildrenRecursively.
private void addChildrenRecursively(VintageTestDescriptor parent) {
if (parent.getDescription().isTest()) {
return;
}
List<Description> children = parent.getDescription().getChildren();
// Use LinkedHashMap to preserve order, ArrayList for fast access by index
Map<String, List<Description>> childrenByUniqueId = children.stream().collect(groupingBy(uniqueIdReader.andThen(uniqueIdStringifier), LinkedHashMap::new, toCollection(ArrayList::new)));
for (Entry<String, List<Description>> entry : childrenByUniqueId.entrySet()) {
String uniqueId = entry.getKey();
List<Description> childrenWithSameUniqueId = entry.getValue();
IntFunction<String> uniqueIdGenerator = determineUniqueIdGenerator(uniqueId, childrenWithSameUniqueId);
for (int index = 0; index < childrenWithSameUniqueId.size(); index++) {
String reallyUniqueId = uniqueIdGenerator.apply(index);
Description description = childrenWithSameUniqueId.get(index);
UniqueId id = parent.getUniqueId().append(VintageTestDescriptor.SEGMENT_TYPE_TEST, reallyUniqueId);
VintageTestDescriptor child = new VintageTestDescriptor(id, description, testSourceProvider.findTestSource(description));
parent.addChild(child);
addChildrenRecursively(child);
}
}
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class EngineTestKit method executeDirectly.
private static void executeDirectly(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest, EngineExecutionListener listener) {
UniqueId engineUniqueId = UniqueId.forEngine(testEngine.getId());
TestDescriptor engineTestDescriptor = testEngine.discover(discoveryRequest, engineUniqueId);
ExecutionRequest request = new ExecutionRequest(engineTestDescriptor, listener, discoveryRequest.getConfigurationParameters());
testEngine.execute(request);
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class UniqueIdParsingForArrayParameterIntegrationTests method executeTestsForPrimitiveArrayMethodInjectionCases.
@Test
void executeTestsForPrimitiveArrayMethodInjectionCases() {
EngineExecutionResults executionResults = executeTestsForClass(PrimitiveArrayMethodInjectionTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
UniqueId uniqueId = executionResults.allEvents().map(Event::getTestDescriptor).distinct().skip(2).map(TestDescriptor::getUniqueId).findFirst().orElseThrow(AssertionError::new);
// @formatter:on
assertThat(UniqueId.parse(uniqueId.toString())).isEqualTo(uniqueId);
}
Aggregations