Search in sources :

Example 21 with ResourceLoader

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

the class CucumberFeatureTest method loads_no_features_when_rerun_file_is_empty.

@Test
public void loads_no_features_when_rerun_file_is_empty() throws Exception {
    String feature = "" + "Feature: bar\n" + "  Scenario: scenario bar\n" + "    * step\n";
    String rerunPath = "path/rerun.txt";
    String rerunFile = "";
    ResourceLoader resourceLoader = mockFeatureFileResourceForAnyFeaturePath(feature);
    mockFileResource(resourceLoader, rerunPath, null, rerunFile);
    List<CucumberFeature> features = CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), new ArrayList<Object>(), new PrintStream(new ByteArrayOutputStream()));
    assertEquals(0, features.size());
}
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 22 with ResourceLoader

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

the class CucumberFeatureTest method applies_line_filters_when_loading_a_feature.

@Test
public void applies_line_filters_when_loading_a_feature() throws Exception {
    String featurePath = "path/foo.feature";
    String feature = "" + "Feature: foo\n" + "  Scenario: scenario 1\n" + "    * step\n" + "  Scenario: scenario 2\n" + "    * step\n";
    ResourceLoader resourceLoader = mockFeatureFileResource(featurePath, feature);
    List<CucumberFeature> features = CucumberFeature.load(resourceLoader, singletonList(featurePath + ":2"), new ArrayList<Object>(), new PrintStream(new ByteArrayOutputStream()));
    assertEquals(1, features.size());
    assertEquals(1, features.get(0).getFeatureElements().size());
    assertEquals("Scenario: scenario 1", features.get(0).getFeatureElements().get(0).getVisualName());
}
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 23 with ResourceLoader

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

the class CucumberFeatureTest method loads_features_specified_in_rerun_file.

@Test
public void loads_features_specified_in_rerun_file() throws Exception {
    String featurePath1 = "path/bar.feature";
    String feature1 = "" + "Feature: bar\n" + "  Scenario: scenario bar\n" + "    * step\n";
    String featurePath2 = "path/foo.feature";
    String feature2 = "" + "Feature: foo\n" + "  Scenario: scenario 1\n" + "    * step\n" + "  Scenario: scenario 2\n" + "    * step\n";
    String rerunPath = "path/rerun.txt";
    String rerunFile = featurePath1 + ":2 " + featurePath2 + ":4";
    ResourceLoader resourceLoader = mockFeatureFileResource(featurePath1, feature1);
    mockFeatureFileResource(resourceLoader, featurePath2, feature2);
    mockFileResource(resourceLoader, rerunPath, null, rerunFile);
    List<CucumberFeature> features = CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), new ArrayList<Object>(), new PrintStream(new ByteArrayOutputStream()));
    assertEquals(2, features.size());
    assertEquals(1, features.get(0).getFeatureElements().size());
    assertEquals("Scenario: scenario bar", features.get(0).getFeatureElements().get(0).getVisualName());
    assertEquals(1, features.get(1).getFeatureElements().size());
    assertEquals("Scenario: scenario 2", features.get(1).getFeatureElements().get(0).getVisualName());
}
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 24 with ResourceLoader

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

the class ScenarioTestCase method createCucumberRuntime.

private Runtime createCucumberRuntime() {
    List<Module> moduleList = new ArrayList<>();
    moduleList.add(new ScenarioModule(new SequentialScenarioScope()));
    moduleList.addAll(testConditions.getModules());
    Injector injector = Guice.createInjector(moduleList);
    ClassLoader classLoader = getClass().getClassLoader();
    ResourceLoader resourceLoader = new MultiLoader(classLoader);
    ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    JavaBackend backend = new JavaBackend(new GuiceObjectFactory(injector), classFinder);
    return new Runtime(resourceLoader, classLoader, Collections.singleton(backend), options);
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) JavaBackend(cucumber.runtime.java.JavaBackend) MultiLoader(cucumber.runtime.io.MultiLoader) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule) ArrayList(java.util.ArrayList) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) Runtime(cucumber.runtime.Runtime) Injector(com.google.inject.Injector) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) ClassFinder(cucumber.runtime.ClassFinder) SequentialScenarioScope(cucumber.runtime.java.guice.impl.SequentialScenarioScope) Module(com.google.inject.Module) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule)

Example 25 with ResourceLoader

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

the class TestMain method queueOdkTests.

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

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