Search in sources :

Example 11 with ResourceLoader

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

the class CucumberFeatureTest method mockFeatureFileResourceForAnyFeaturePath.

private ResourceLoader mockFeatureFileResourceForAnyFeaturePath(String feature) throws IOException {
    ResourceLoader resourceLoader = mock(ResourceLoader.class);
    Resource resource = mock(Resource.class);
    when(resource.getPath()).thenReturn("");
    when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(feature.getBytes("UTF-8")));
    when(resourceLoader.resources(anyString(), anyString())).thenReturn(singletonList(resource));
    return resourceLoader;
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) Resource(cucumber.runtime.io.Resource)

Example 12 with ResourceLoader

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

the class RuntimeTest method should_pass_if_no_features_are_found.

@Test
public void should_pass_if_no_features_are_found() throws IOException {
    ResourceLoader resourceLoader = createResourceLoaderThatFindsNoFeatures();
    Runtime runtime = createStrictRuntime(resourceLoader);
    runtime.run();
    assertEquals(0x0, runtime.exitStatus());
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Test(org.junit.Test)

Example 13 with ResourceLoader

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

the class RuntimeTest method createResourceLoaderThatFindsNoFeatures.

private ResourceLoader createResourceLoaderThatFindsNoFeatures() {
    ResourceLoader resourceLoader = mock(ResourceLoader.class);
    when(resourceLoader.resources(anyString(), eq(".feature"))).thenReturn(Collections.<Resource>emptyList());
    return resourceLoader;
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader)

Example 14 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project activityinfo by bedatadriven.

the class TestMain method queueUiTests.

private void queueUiTests() {
    ResourceLoader loader = new MultiLoader(getClass().getClassLoader());
    RuntimeOptions options = new RuntimeOptions(Arrays.asList("--tags", "@web", "classpath:org/activityinfo/test", "--glue", "org.activityinfo.test.steps.common", "--glue", "org.activityinfo.test.steps.web"));
    queueFeatures("ui", loader, options, new WebDriverModule(webDriverType));
    queueTestMethods("ui", new WebDriverModule(webDriverType));
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) WebDriverModule(org.activityinfo.test.webdriver.WebDriverModule) MultiLoader(cucumber.runtime.io.MultiLoader) RuntimeOptions(cucumber.runtime.RuntimeOptions)

Example 15 with ResourceLoader

use of cucumber.runtime.io.ResourceLoader in project page-factory-2 by sbtqa.

the class FragmentCacheUtils method cacheFragmentsToFeatures.

static List<CucumberFeature> cacheFragmentsToFeatures(Class clazz, List<CucumberFeature> features) {
    if (PROPERTIES.getFragmentsPath().isEmpty()) {
        return features;
    } else {
        ClassLoader classLoader = clazz.getClassLoader();
        ResourceLoader resourceLoader = new MultiLoader(classLoader);
        List<CucumberFeature> fragmentsRaw = new FeatureLoader(resourceLoader).load(Collections.singletonList(FeaturePath.parse(PROPERTIES.getFragmentsPath())));
        return Stream.concat(features.stream(), fragmentsRaw.stream()).collect(Collectors.toList());
    }
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) CucumberFeature(cucumber.runtime.model.CucumberFeature) MultiLoader(cucumber.runtime.io.MultiLoader) FeatureLoader(cucumber.runtime.model.FeatureLoader)

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