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());
}
}
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());
}
}
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());
}
}
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;
}
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());
}
Aggregations