Search in sources :

Example 11 with DiscoverySelector

use of org.junit.platform.engine.DiscoverySelector in project cucumber-jvm by cucumber.

the class DiscoverySelectorResolverTest method resolveRequestWithClassPathUriSelectorWithLine.

@Test
void resolveRequestWithClassPathUriSelectorWithLine() {
    URI uri = URI.create("classpath:/io/cucumber/junit/platform/engine/feature-with-outline.feature?line=20");
    DiscoverySelector resource = selectUri(uri);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    List<? extends TestDescriptor> tests = testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).collect(Collectors.toList());
    assertEquals(1, tests.size());
}
Also used : URI(java.net.URI) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 12 with DiscoverySelector

use of org.junit.platform.engine.DiscoverySelector in project cucumber-jvm by cucumber.

the class DiscoverySelectorResolverTest method resolveRequestWithClasspathResourceSelector.

@Test
void resolveRequestWithClasspathResourceSelector() {
    DiscoverySelector resource = selectClasspathResource("io/cucumber/junit/platform/engine/single.feature");
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(1, testDescriptor.getChildren().size());
}
Also used : DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 13 with DiscoverySelector

use of org.junit.platform.engine.DiscoverySelector in project cucumber-jvm by cucumber.

the class DiscoverySelectorResolverTest method resolveRequestWithUriSelectorWithScenarioOutlineLine.

@Test
void resolveRequestWithUriSelectorWithScenarioOutlineLine() {
    File file = new File("src/test/resources/io/cucumber/junit/platform/engine/feature-with-outline.feature");
    URI uri = URI.create(file.toURI() + "?line=11");
    DiscoverySelector resource = selectUri(uri);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    List<? extends TestDescriptor> tests = testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).collect(Collectors.toList());
    // 4 examples in the outline
    assertEquals(4, tests.size());
}
Also used : File(java.io.File) DiscoverySelectors.selectFile(org.junit.platform.engine.discovery.DiscoverySelectors.selectFile) URI(java.net.URI) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 14 with DiscoverySelector

use of org.junit.platform.engine.DiscoverySelector in project cucumber-jvm by cucumber.

the class DiscoverySelectorResolverTest method resolveRequestWithUniqueIdSelectorFromJarFileUri.

@Test
void resolveRequestWithUniqueIdSelectorFromJarFileUri() {
    URI uri = new File("src/test/resources/feature.jar").toURI();
    DiscoverySelector resource = selectUri(uri);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(1, testDescriptor.getChildren().size());
}
Also used : URI(java.net.URI) File(java.io.File) DiscoverySelectors.selectFile(org.junit.platform.engine.discovery.DiscoverySelectors.selectFile) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 15 with DiscoverySelector

use of org.junit.platform.engine.DiscoverySelector in project gradle by gradle.

the class ToolingApiCurrentDiscoveryRequest method getSelectorsByType.

@Override
public <T extends DiscoverySelector> List<T> getSelectorsByType(Class<T> selectorType) {
    if (selectorType.equals(ClassSelector.class)) {
        return Cast.uncheckedCast(selectors);
    }
    if (selectorType.equals(DiscoverySelector.class)) {
        List<DiscoverySelector> result = new ArrayList<DiscoverySelector>(delegate.getSelectorsByType(selectorType));
        Iterator<DiscoverySelector> iterator = result.iterator();
        while (iterator.hasNext()) {
            DiscoverySelector selector = iterator.next();
            if (selector instanceof ClassSelector) {
                iterator.remove();
            }
        }
        result.addAll(selectors);
        return Cast.uncheckedCast(result);
    }
    return delegate.getSelectorsByType(selectorType);
}
Also used : ClassSelector(org.junit.platform.engine.discovery.ClassSelector) ArrayList(java.util.ArrayList) DiscoverySelector(org.junit.platform.engine.DiscoverySelector)

Aggregations

DiscoverySelector (org.junit.platform.engine.DiscoverySelector)27 Test (org.junit.jupiter.api.Test)23 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)23 URI (java.net.URI)7 TestDescriptor (org.junit.platform.engine.TestDescriptor)6 File (java.io.File)5 DiscoverySelectors.selectFile (org.junit.platform.engine.discovery.DiscoverySelectors.selectFile)5 FilePosition (org.junit.platform.engine.discovery.FilePosition)5 ArrayList (java.util.ArrayList)3 Path (java.nio.file.Path)2 HashSet (java.util.HashSet)2 LogRecord (java.util.logging.LogRecord)2 UniqueId (org.junit.platform.engine.UniqueId)2 DiscoverySelectors (org.junit.platform.engine.discovery.DiscoverySelectors)2 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)2 LauncherDiscoveryRequestBuilder (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder)2 LogRecordListener (io.cucumber.core.logging.LogRecordListener)1 LoggerFactory (io.cucumber.core.logging.LoggerFactory)1 NoFeatures (io.cucumber.junit.platform.engine.nofeatures.NoFeatures)1 BufferedReader (java.io.BufferedReader)1