Search in sources :

Example 6 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.

the class CucumberFeatureTest method gives_error_message_if_filters_conflicts_with_path_from_rerun_file_on_file_system.

@Test
public void gives_error_message_if_filters_conflicts_with_path_from_rerun_file_on_file_system() throws Exception {
    String featurePath = "path/bar.feature";
    String rerunPath = "path/rerun.txt";
    String rerunFile = featurePath + ":2";
    ResourceLoader resourceLoader = mockFeatureFileResource(featurePath, "");
    mockFileResource(resourceLoader, rerunPath, suffix(null), rerunFile);
    try {
        CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), Collections.<Object>singletonList("@Tag"), new PrintStream(new ByteArrayOutputStream()));
        fail("IllegalArgumentException was expected");
    } catch (IllegalArgumentException exception) {
        assertEquals("Inconsistent filters: [@Tag, 2]. Only one type [line,name,tag] can be used at once.", exception.getMessage());
    }
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) PrintStream(java.io.PrintStream) Matchers.anyString(org.mockito.Matchers.anyString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 7 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.

the class CucumberFeatureTest method gives_error_message_if_filters_conflicts_with_path_from_rerun_file_on_classpath.

@Test
public void gives_error_message_if_filters_conflicts_with_path_from_rerun_file_on_classpath() throws Exception {
    String featurePath = "path/bar.feature";
    String rerunPath = "path/rerun.txt";
    String rerunFile = featurePath + ":2";
    ResourceLoader resourceLoader = mockFeatureFileResource("classpath:" + featurePath, "");
    mockFeaturePathToNotExist(resourceLoader, featurePath);
    mockFileResource(resourceLoader, rerunPath, suffix(null), rerunFile);
    try {
        CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), Collections.<Object>singletonList("@Tag"), new PrintStream(new ByteArrayOutputStream()));
        fail("IllegalArgumentException was expected");
    } catch (IllegalArgumentException exception) {
        assertEquals("Inconsistent filters: [@Tag, 2]. Only one type [line,name,tag] can be used at once.", exception.getMessage());
    }
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) PrintStream(java.io.PrintStream) Matchers.anyString(org.mockito.Matchers.anyString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 8 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.

the class CucumberFeatureTest method gives_error_message_if_path_from_rerun_file_does_not_exist.

@Test
public void gives_error_message_if_path_from_rerun_file_does_not_exist() throws Exception {
    String featurePath = "path/bar.feature";
    String rerunPath = "path/rerun.txt";
    String rerunFile = featurePath + ":2";
    ResourceLoader resourceLoader = mock(ResourceLoader.class);
    mockFeaturePathToNotExist(resourceLoader, featurePath);
    mockFeaturePathToNotExist(resourceLoader, "classpath:" + featurePath);
    mockFileResource(resourceLoader, rerunPath, suffix(null), rerunFile);
    try {
        CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), new ArrayList<Object>(), new PrintStream(new ByteArrayOutputStream()));
        fail("IllegalArgumentException was expected");
    } catch (IllegalArgumentException exception) {
        assertEquals("Neither found on file system or on classpath: " + "Not a file or directory: path/bar.feature, No resource found for: classpath:path/bar.feature", exception.getMessage());
    }
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) PrintStream(java.io.PrintStream) Matchers.anyString(org.mockito.Matchers.anyString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 9 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.

the class CucumberFeatureTest method mockFeatureFileResource.

private ResourceLoader mockFeatureFileResource(String featurePath, String feature) throws IOException {
    ResourceLoader resourceLoader = mock(ResourceLoader.class);
    mockFeatureFileResource(resourceLoader, featurePath, feature);
    return resourceLoader;
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader)

Example 10 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.

the class CucumberFeatureTest method logs_message_if_no_features_are_found.

@Test
public void logs_message_if_no_features_are_found() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ResourceLoader resourceLoader = mock(ResourceLoader.class);
    when(resourceLoader.resources("does/not/exist", ".feature")).thenReturn(Collections.<Resource>emptyList());
    CucumberFeature.load(resourceLoader, singletonList("does/not/exist"), emptyList(), new PrintStream(baos));
    assertEquals(String.format("No features found at [does/not/exist]%n"), baos.toString());
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

ResourceLoader (cucumber.runtime.io.ResourceLoader)26 Test (org.junit.Test)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 PrintStream (java.io.PrintStream)11 MultiLoader (cucumber.runtime.io.MultiLoader)7 Matchers.anyString (org.mockito.Matchers.anyString)7 RuntimeOptions (cucumber.runtime.RuntimeOptions)5 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)4 ClassFinder (cucumber.runtime.ClassFinder)3 Runtime (cucumber.runtime.Runtime)3 ResourceLoaderClassFinder (cucumber.runtime.io.ResourceLoaderClassFinder)3 ObjectFactory (cucumber.api.java.ObjectFactory)2 JavaBackend (cucumber.runtime.java.JavaBackend)2 CucumberFeature (cucumber.runtime.model.CucumberFeature)2 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 OsgiClassFinder (cucumber.java.runtime.osgi.OsgiClassFinder)1 PaxExamObjectFactory (cucumber.java.runtime.osgi.PaxExamObjectFactory)1 Backend (cucumber.runtime.Backend)1 CucumberException (cucumber.runtime.CucumberException)1