Search in sources :

Example 21 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithFileSelectorAndPositionOfContainer.

@Test
void resolveRequestWithFileSelectorAndPositionOfContainer() {
    String feature = "src/test/resources/io/cucumber/junit/platform/engine/rule.feature";
    FilePosition line = FilePosition.from(3);
    DiscoverySelector resource = selectFile(feature, line);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(2L, testDescriptor.getDescendants().stream().filter(TestDescriptor::isTest).count());
}
Also used : FilePosition(org.junit.platform.engine.discovery.FilePosition) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor) Test(org.junit.jupiter.api.Test)

Example 22 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithUniqueIdSelectorFromClasspath.

@Test
void resolveRequestWithUniqueIdSelectorFromClasspath() {
    DiscoverySelector resource = selectPackage("io.cucumber.junit.platform.engine");
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    Set<? extends TestDescriptor> descendants = testDescriptor.getDescendants();
    descendants.forEach(targetDescriptor -> {
        resetTestDescriptor();
        resolveRequestWithUniqueIdSelector(targetDescriptor.getUniqueId());
        assertEquals(1, testDescriptor.getChildren().size());
        assertThat(testDescriptor, allDescriptorsPrefixedBy(targetDescriptor.getUniqueId()));
    });
}
Also used : DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 23 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithDirectorySelector.

@Test
void resolveRequestWithDirectorySelector() {
    DiscoverySelector resource = selectDirectory("src/test/resources/io/cucumber/junit/platform/engine");
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(5, testDescriptor.getChildren().size());
}
Also used : DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 24 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithUriSelectorWithExamplesSectionLine.

@Test
void resolveRequestWithUriSelectorWithExamplesSectionLine() {
    File file = new File("src/test/resources/io/cucumber/junit/platform/engine/feature-with-outline.feature");
    URI uri = URI.create(file.toURI() + "?line=17");
    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());
    // 2 examples in the examples section
    assertEquals(2, 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 25 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithClassSelector.

@Test
void resolveRequestWithClassSelector() {
    DiscoverySelector resource = selectClass(RunCucumberTest.class);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(5, testDescriptor.getChildren().size());
}
Also used : DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

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