use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method applies_line_filters_only_to_own_feature.
@Test
public void applies_line_filters_only_to_own_feature() throws Exception {
String featurePath1 = "path/bar.feature";
String feature1 = "" + "Feature: bar\n" + " Scenario: scenario_1_1\n" + " * step\n" + " Scenario: scenario_1_2\n" + " * step\n";
String featurePath2 = "path/foo.feature";
String feature2 = "" + "Feature: foo\n" + " Scenario: scenario_2_1\n" + " * step\n" + " Scenario: scenario_2_2\n" + " * step\n";
ResourceLoader resourceLoader = mock(ResourceLoader.class);
mockResource(resourceLoader, featurePath1, feature1);
mockResource(resourceLoader, featurePath2, feature2);
RuntimeOptions options = new RuntimeOptions(featurePath1 + ":2 " + featurePath2 + ":4");
List<CucumberFeature> features = options.cucumberFeatures(resourceLoader);
assertEquals(2, features.size());
assertOnlyScenarioName(features.get(0), "scenario_1_1");
assertOnlyScenarioName(features.get(1), "scenario_2_2");
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class CalculatorTest method cucumber.
@Test
public void cucumber() throws Exception {
assertNotNull(injector);
assertNotNull(bundleContext);
final ResourceLoader resourceLoader = new FileResourceLoader();
final ClassLoader classLoader = Runtime.class.getClassLoader();
final ObjectFactory objectFactory = new PaxExamObjectFactory(injector);
final ClassFinder classFinder = new OsgiClassFinder(bundleContext);
final Backend backend = new JavaBackend(objectFactory, classFinder);
final RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(getClass());
final RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
final Runtime runtime = new Runtime(resourceLoader, classLoader, Collections.singleton(backend), runtimeOptions);
runtime.run();
if (!runtime.getErrors().isEmpty()) {
throw new CucumberException(runtime.getErrors().get(0));
} else if (runtime.exitStatus() != 0x00) {
throw new CucumberException("There are pending or undefined steps.");
}
assertEquals(runtime.getErrors().size(), 0);
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method succeds_if_no_features_are_found.
@Test
public void succeds_if_no_features_are_found() {
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(new ByteArrayOutputStream()));
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method loads_features_specified_in_rerun_file_from_classpath_when_not_in_file_system.
@Test
public void loads_features_specified_in_rerun_file_from_classpath_when_not_in_file_system() throws Exception {
String featurePath = "path/bar.feature";
String feature = "" + "Feature: bar\n" + " Scenario: scenario bar\n" + " * step\n";
String rerunPath = "path/rerun.txt";
String rerunFile = featurePath + ":2";
ResourceLoader resourceLoader = mockFeatureFileResource("classpath:" + featurePath, feature);
mockFeaturePathToNotExist(resourceLoader, featurePath);
mockFileResource(resourceLoader, rerunPath, suffix(null), rerunFile);
List<CucumberFeature> features = CucumberFeature.load(resourceLoader, singletonList("@" + rerunPath), new ArrayList<Object>(), new PrintStream(new ByteArrayOutputStream()));
assertEquals(1, features.size());
assertEquals(1, features.get(0).getFeatureElements().size());
assertEquals("Scenario: scenario bar", features.get(0).getFeatureElements().get(0).getVisualName());
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method logs_message_if_features_are_found_but_filters_are_too_strict.
@Test
public void logs_message_if_features_are_found_but_filters_are_too_strict() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ResourceLoader resourceLoader = mockFeatureFileResource("features", "Feature: foo");
CucumberFeature.load(resourceLoader, singletonList("features"), singletonList((Object) "@nowhere"), new PrintStream(baos));
assertEquals(String.format("None of the features at [features] matched the filters: [@nowhere]%n"), baos.toString());
}
Aggregations