use of org.junit.platform.engine.UniqueId in project cucumber-jvm by cucumber.
the class FeatureResolver method resolveUniqueId.
void resolveUniqueId(UniqueIdSelector uniqueIdSelector) {
UniqueId uniqueId = uniqueIdSelector.getUniqueId();
// Ignore any ids not from our own engine
if (!uniqueId.hasPrefix(engineDescriptor.getUniqueId())) {
return;
}
Predicate<TestDescriptor> keepTestWithSelectedId = testDescriptor -> uniqueId.equals(testDescriptor.getUniqueId());
uniqueId.getSegments().stream().filter(FeatureOrigin::isFeatureSegment).map(UniqueId.Segment::getValue).map(URI::create).flatMap(this::resolveUri).forEach(featureDescriptor -> {
featureDescriptor.prune(keepTestWithSelectedId);
engineDescriptor.mergeFeature(featureDescriptor);
});
}
use of org.junit.platform.engine.UniqueId in project cucumber-jvm by cucumber.
the class DiscoverySelectorResolverTest method resolveRequestWithMultipleUniqueIdSelector.
@Test
void resolveRequestWithMultipleUniqueIdSelector() {
Set<UniqueId> selectors = new HashSet<>();
DiscoverySelector resource = selectDirectory("src/test/resources/io/cucumber/junit/platform/engine/feature-with-outline.feature");
selectSomePickle(resource).ifPresent(selectors::add);
DiscoverySelector resource2 = selectDirectory("src/test/resources/io/cucumber/junit/platform/engine/single.feature");
selectSomePickle(resource2).ifPresent(selectors::add);
EngineDiscoveryRequest discoveryRequest = new SelectorRequest(selectors.stream().map(DiscoverySelectors::selectUniqueId).collect(Collectors.toList()));
resolver.resolveSelectors(discoveryRequest, testDescriptor);
assertEquals(selectors, testDescriptor.getDescendants().stream().filter(PickleDescriptor.class::isInstance).map(TestDescriptor::getUniqueId).collect(toSet()));
}
use of org.junit.platform.engine.UniqueId in project graylog2-server by Graylog2.
the class ContainerMatrixTestEngine method discover.
@Override
public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) {
JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters()));
final ContainerMatrixEngineDescriptor engineDescriptor = new ContainerMatrixEngineDescriptor(uniqueId, "Graylog Container Matrix Tests", configuration);
Reflections reflections = new Reflections("org.graylog", "org.graylog2");
final Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(ContainerMatrixTestsConfiguration.class);
final Set<Integer> extraPorts = getExtraPorts(annotated);
final List<URL> mongoDBFixtures = getMongoDBFixtures(annotated);
if (testAgainstRunningESMongoDB()) {
// if you test from inside an IDE against running containers
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestWithRunningESMongoTestsDescriptor(engineDescriptor, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
} else {
// for full tests, create all combinations of tests. First differentiate for maven builds.
getMavenProjectDirProvider(annotated).forEach(mavenProjectDirProvider -> getPluginJarsProvider(annotated).forEach(pluginJarsProvider -> {
MavenProjectDirProvider mpdp = instantiateFactory(mavenProjectDirProvider);
PluginJarsProvider pjp = instantiateFactory(pluginJarsProvider);
// now add all grouped tests for Lifecycle.VM
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(searchVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.VM, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), searchVersion, mongoVersion, extraPorts, mongoDBFixtures);
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
// add separate test classes (Lifecycle.CLASS)
getSearchServerVersions(annotated).stream().map(SearchServer::getSearchVersion).forEach(esVersion -> getMongoVersions(annotated).forEach(mongoVersion -> {
ContainerMatrixTestsDescriptor testsDescriptor = new ContainerMatrixTestsDescriptor(engineDescriptor, Lifecycle.CLASS, mavenProjectDirProvider, mpdp.getUniqueId(), pluginJarsProvider, pjp.getUniqueId(), esVersion, mongoVersion, extraPorts, new ArrayList<>());
new ContainerMatrixTestsDiscoverySelectorResolver(engineDescriptor).resolveSelectors(discoveryRequest, testsDescriptor);
engineDescriptor.addChild(testsDescriptor);
}));
}));
}
return engineDescriptor;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestTemplateTestDescriptorTests method inheritsTagsFromParent.
@Test
void inheritsTagsFromParent() throws Exception {
UniqueId rootUniqueId = UniqueId.root("segment", "template");
UniqueId parentUniqueId = rootUniqueId.append("class", "myClass");
AbstractTestDescriptor parent = containerTestDescriptorWithTags(parentUniqueId, singleton(TestTag.create("foo")));
when(jupiterConfiguration.getDefaultDisplayNameGenerator()).thenReturn(new DisplayNameGenerator.Standard());
TestTemplateTestDescriptor testDescriptor = new TestTemplateTestDescriptor(parentUniqueId.append("tmp", "testTemplate()"), MyTestCase.class, MyTestCase.class.getDeclaredMethod("testTemplate"), jupiterConfiguration);
parent.addChild(testDescriptor);
assertThat(testDescriptor.getTags()).containsExactlyInAnyOrder(TestTag.create("foo"), TestTag.create("bar"), TestTag.create("baz"));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class OtherClass method resolvingUniqueIdWithUnknownSegmentTypeResolvesNothing.
@Test
void resolvingUniqueIdWithUnknownSegmentTypeResolvesNothing() {
UniqueId uniqueId = engineId().append("bogus", "enigma");
UniqueIdSelector selector = selectUniqueId(uniqueId);
resolve(request().selectors(selector));
assertTrue(engineDescriptor.getDescendants().isEmpty());
assertUnresolved(selector);
}
Aggregations