Search in sources :

Example 6 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithClassSelectorShouldLogWarnIfNoFeaturesFound.

@Test
void resolveRequestWithClassSelectorShouldLogWarnIfNoFeaturesFound() {
    DiscoverySelector resource = selectClass(NoFeatures.class);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(0, testDescriptor.getChildren().size());
    assertEquals(1, logRecordListener.getLogRecords().size());
    LogRecord logRecord = logRecordListener.getLogRecords().get(0);
    assertEquals(Level.WARNING, logRecord.getLevel());
    assertEquals("No features found in package 'io.cucumber.junit.platform.engine.nofeatures'", logRecord.getMessage());
}
Also used : LogRecord(java.util.logging.LogRecord) DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 7 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithFileSelectorAndPosition.

@Test
void resolveRequestWithFileSelectorAndPosition() {
    String feature = "src/test/resources/io/cucumber/junit/platform/engine/rule.feature";
    FilePosition line = FilePosition.from(5);
    DiscoverySelector resource = selectFile(feature, line);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(1L, 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 8 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithClasspathResourceSelectorAndFilePositionOfContainer.

@Test
void resolveRequestWithClasspathResourceSelectorAndFilePositionOfContainer() {
    String feature = "io/cucumber/junit/platform/engine/rule.feature";
    FilePosition line = FilePosition.from(3);
    DiscoverySelector resource = selectClasspathResource(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 9 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method ignoreRequestWithUniqueIdSelectorFromDifferentEngine.

@Test
void ignoreRequestWithUniqueIdSelectorFromDifferentEngine() {
    DiscoverySelector selector = selectUniqueId(UniqueId.forEngine("not-cucumber"));
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(selector);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertTrue(testDescriptor.getDescendants().isEmpty());
}
Also used : DiscoverySelector(org.junit.platform.engine.DiscoverySelector) EngineDiscoveryRequest(org.junit.platform.engine.EngineDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 10 with DiscoverySelector

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

the class DiscoverySelectorResolverTest method resolveRequestWithUniqueIdSelectorFromJarUri.

@Test
void resolveRequestWithUniqueIdSelectorFromJarUri() {
    String root = Paths.get("").toAbsolutePath().toUri().getSchemeSpecificPart();
    URI uri = URI.create("jar:file:" + root + "/src/test/resources/feature.jar!/single.feature");
    DiscoverySelector resource = selectUri(uri);
    EngineDiscoveryRequest discoveryRequest = new SelectorRequest(resource);
    resolver.resolveSelectors(discoveryRequest, testDescriptor);
    assertEquals(1, testDescriptor.getChildren().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)

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