diff --git a/core/src/main/java/cucumber/api/cli/Main.java b/core/src/main/java/cucumber/api/cli/Main.java index cb182a7cff..1d8564acd0 100644 --- a/core/src/main/java/cucumber/api/cli/Main.java +++ b/core/src/main/java/cucumber/api/cli/Main.java @@ -1,7 +1,6 @@ package cucumber.api.cli; import cucumber.runtime.ClassFinder; -import cucumber.runtime.Env; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeOptions; import cucumber.runtime.io.MultiLoader; @@ -9,6 +8,9 @@ import cucumber.runtime.io.ResourceLoaderClassFinder; import java.io.IOException; +import java.util.ArrayList; + +import static java.util.Arrays.asList; public class Main { @@ -17,7 +19,7 @@ public static void main(String[] argv) throws Throwable { } public static void run(String[] argv, ClassLoader classLoader) throws IOException { - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), argv); + RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList(asList(argv))); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); diff --git a/core/src/main/java/cucumber/runtime/RuntimeOptions.java b/core/src/main/java/cucumber/runtime/RuntimeOptions.java index 66f90b68ac..741917f033 100644 --- a/core/src/main/java/cucumber/runtime/RuntimeOptions.java +++ b/core/src/main/java/cucumber/runtime/RuntimeOptions.java @@ -21,7 +21,6 @@ import java.util.regex.Pattern; import static cucumber.runtime.model.CucumberFeature.load; -import static java.util.Arrays.asList; // IMPORTANT! Make sure USAGE.txt is always uptodate if this class changes. public class RuntimeOptions { @@ -41,14 +40,41 @@ public class RuntimeOptions { private boolean monochrome = false; private SnippetType snippetType = SnippetType.UNDERSCORE; - public RuntimeOptions(Env env, String... argv) { + /** + * Create a new instance from a string of options, for example: + * + * + * + * @param argv the arguments + */ + public RuntimeOptions(String argv) { + this(new FormatterFactory(), shellWords(argv)); + } + + /** + * Create a new instance from a list of options, for example: + * + * + * + * @param argv the arguments + */ + public RuntimeOptions(List argv) { + this(new FormatterFactory(), argv); + } + + public RuntimeOptions(Env env, List argv) { this(env, new FormatterFactory(), argv); } - RuntimeOptions(Env env, FormatterFactory formatterFactory, String... argv) { + public RuntimeOptions(FormatterFactory formatterFactory, List argv) { + this(new Env("cucumber-jvm"), formatterFactory, argv); + } + + public RuntimeOptions(Env env, FormatterFactory formatterFactory, List argv) { this.formatterFactory = formatterFactory; - parse(new ArrayList(asList(argv))); + argv = new ArrayList(argv); // in case the one passed in is unmodifiable. + parse(argv); String cucumberOptionsFromEnv = env.get("cucumber.options"); if (cucumberOptionsFromEnv != null) { @@ -62,7 +88,7 @@ public RuntimeOptions(Env env, String... argv) { setFormatterOptions(); } - private List shellWords(String cmdline) { + private static List shellWords(String cmdline) { List matchList = new ArrayList(); Matcher shellwordsMatcher = SHELLWORDS_PATTERN.matcher(cmdline); while (shellwordsMatcher.find()) { diff --git a/core/src/main/java/cucumber/runtime/RuntimeOptionsFactory.java b/core/src/main/java/cucumber/runtime/RuntimeOptionsFactory.java index 38f2e3d1fa..1bde737de3 100644 --- a/core/src/main/java/cucumber/runtime/RuntimeOptionsFactory.java +++ b/core/src/main/java/cucumber/runtime/RuntimeOptionsFactory.java @@ -21,8 +21,7 @@ public RuntimeOptionsFactory(Class clazz, Class[] annotati public RuntimeOptions create() { List args = buildArgsFromOptions(); - - return new RuntimeOptions(new Env("cucumber-jvm"), args.toArray(new String[args.size()])); + return new RuntimeOptions(args); } private List buildArgsFromOptions() { diff --git a/core/src/test/java/cucumber/runtime/BackgroundTest.java b/core/src/test/java/cucumber/runtime/BackgroundTest.java index 5377d77b93..db1fe6892d 100644 --- a/core/src/test/java/cucumber/runtime/BackgroundTest.java +++ b/core/src/test/java/cucumber/runtime/BackgroundTest.java @@ -16,7 +16,7 @@ public class BackgroundTest { @Test public void should_run_background() throws IOException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + RuntimeOptions runtimeOptions = new RuntimeOptions(""); Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(mock(Backend.class)), runtimeOptions); CucumberFeature feature = feature("test.feature", "" + "Feature:\n" + diff --git a/core/src/test/java/cucumber/runtime/HookOrderTest.java b/core/src/test/java/cucumber/runtime/HookOrderTest.java index 1bbc08fa83..16bef88331 100644 --- a/core/src/test/java/cucumber/runtime/HookOrderTest.java +++ b/core/src/test/java/cucumber/runtime/HookOrderTest.java @@ -29,7 +29,7 @@ public class HookOrderTest { @Before public void buildMockWorld() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + RuntimeOptions runtimeOptions = new RuntimeOptions(""); runtime = new Runtime(mock(ResourceLoader.class), classLoader, asList(mock(Backend.class)), runtimeOptions); runtime.buildBackendWorlds(null, Collections.emptySet()); glue = runtime.getGlue(); diff --git a/core/src/test/java/cucumber/runtime/HookTest.java b/core/src/test/java/cucumber/runtime/HookTest.java index ba341bc57e..a1774edd7b 100644 --- a/core/src/test/java/cucumber/runtime/HookTest.java +++ b/core/src/test/java/cucumber/runtime/HookTest.java @@ -43,7 +43,7 @@ public void after_hooks_execute_before_objects_are_disposed() throws Throwable { CucumberScenario scenario = new CucumberScenario(feature, null, gherkinScenario); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + RuntimeOptions runtimeOptions = new RuntimeOptions(""); Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(backend), runtimeOptions); runtime.getGlue().addAfterHook(hook); diff --git a/core/src/test/java/cucumber/runtime/RuntimeOptionsTest.java b/core/src/test/java/cucumber/runtime/RuntimeOptionsTest.java index 895d60e964..176dd88c82 100644 --- a/core/src/test/java/cucumber/runtime/RuntimeOptionsTest.java +++ b/core/src/test/java/cucumber/runtime/RuntimeOptionsTest.java @@ -1,15 +1,16 @@ package cucumber.runtime; import cucumber.api.SnippetType; -import org.junit.Test; import cucumber.runtime.formatter.ColorAware; import cucumber.runtime.formatter.FormatterFactory; import cucumber.runtime.formatter.StrictAware; import gherkin.formatter.Formatter; +import org.junit.Test; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; +import java.util.Collections; import java.util.Properties; import java.util.regex.Pattern; @@ -36,76 +37,76 @@ public void has_usage() { @Test public void assigns_feature_paths() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--glue", "somewhere", "somewhere_else"); + RuntimeOptions options = new RuntimeOptions("--glue somewhere somewhere_else"); assertEquals(asList("somewhere_else"), options.getFeaturePaths()); } @Test public void assigns_line_filters_from_feature_paths() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--glue", "somewhere", "somewhere_else:3"); + RuntimeOptions options = new RuntimeOptions("--glue somewhere somewhere_else:3"); assertEquals(asList("somewhere_else"), options.getFeaturePaths()); assertEquals(asList(3L), options.getFilters()); } @Test public void assigns_filters_and_line_filters_from_feature_paths() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--tags", "@keep_this", "somewhere_else:3"); + RuntimeOptions options = new RuntimeOptions("--tags @keep_this somewhere_else:3"); assertEquals(asList("somewhere_else"), options.getFeaturePaths()); assertEquals(Arrays.asList("@keep_this", 3L), options.getFilters()); } @Test public void strips_options() { - RuntimeOptions options = new RuntimeOptions(new Env(), " --glue ", "somewhere", "somewhere_else"); + RuntimeOptions options = new RuntimeOptions(" --glue somewhere somewhere_else"); assertEquals(asList("somewhere_else"), options.getFeaturePaths()); } @Test public void assigns_glue() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions("--glue somewhere"); assertEquals(asList("somewhere"), options.getGlue()); } @Test public void assigns_dotcucumber() throws MalformedURLException { - RuntimeOptions options = new RuntimeOptions(new Env(), "--dotcucumber", "somewhere", "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions(asList("--dotcucumber", "somewhere", "--glue", "somewhere")); assertEquals(new URL("file:somewhere/"), options.getDotCucumber()); } @Test public void creates_formatter() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--format", "html:some/dir", "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions(asList("--format", "html:some/dir", "--glue", "somewhere")); assertEquals("cucumber.runtime.formatter.HTMLFormatter", options.getFormatters().get(0).getClass().getName()); } @Test public void assigns_strict() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--strict", "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions(asList("--strict", "--glue", "somewhere")); assertTrue(options.isStrict()); } @Test public void assigns_strict_short() { - RuntimeOptions options = new RuntimeOptions(new Env(), "-s", "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions(asList("-s", "--glue", "somewhere")); assertTrue(options.isStrict()); } @Test public void default_strict() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--glue", "somewhere"); + RuntimeOptions options = new RuntimeOptions(asList("--glue", "somewhere")); assertFalse(options.isStrict()); } @Test public void name_without_spaces_is_preserved() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--name", "someName"); + RuntimeOptions options = new RuntimeOptions(asList("--name", "someName")); Pattern actualPattern = (Pattern) options.getFilters().iterator().next(); assertEquals("someName", actualPattern.pattern()); } @Test public void name_with_spaces_is_preserved() { - RuntimeOptions options = new RuntimeOptions(new Env(), "--name", "some Name"); + RuntimeOptions options = new RuntimeOptions(asList("--name", "some Name")); Pattern actualPattern = (Pattern) options.getFilters().iterator().next(); assertEquals("some Name", actualPattern.pattern()); } @@ -114,16 +115,21 @@ public void name_with_spaces_is_preserved() { public void ensure_name_with_spaces_works_with_cucumber_options() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--name 'some Name'"); - RuntimeOptions options = new RuntimeOptions(new Env(properties)); + RuntimeOptions options = new RuntimeOptions(new Env(properties), Collections.emptyList()); + Pattern actualPattern = (Pattern) options.getFilters().iterator().next(); + assertEquals("some Name", actualPattern.pattern()); + } + + @Test + public void ensure_name_with_spaces_works_with_args() { + RuntimeOptions options = new RuntimeOptions("--name 'some Name'"); Pattern actualPattern = (Pattern) options.getFilters().iterator().next(); assertEquals("some Name", actualPattern.pattern()); } @Test public void ensure_multiple_cucumber_options_with_spaces_parse_correctly() throws MalformedURLException { - Properties properties = new Properties(); - properties.setProperty("cucumber.options", "--name 'some Name' --dotcucumber 'some file\\path'"); - RuntimeOptions options = new RuntimeOptions(new Env(properties)); + RuntimeOptions options = new RuntimeOptions("--name 'some Name' --dotcucumber 'some file\\path'"); Pattern actualPattern = (Pattern) options.getFilters().iterator().next(); assertEquals("some Name", actualPattern.pattern()); assertEquals(new URL("file:some file\\path/"), options.getDotCucumber()); @@ -133,7 +139,7 @@ public void ensure_multiple_cucumber_options_with_spaces_parse_correctly() throw public void overrides_options_with_system_properties_without_clobbering_non_overridden_ones() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--glue lookatme this_clobbers_feature_paths"); - RuntimeOptions options = new RuntimeOptions(new Env(properties), "--strict", "--glue", "somewhere", "somewhere_else"); + RuntimeOptions options = new RuntimeOptions(new Env(properties), asList("--strict", "--glue", "somewhere", "somewhere_else")); assertEquals(asList("this_clobbers_feature_paths"), options.getFeaturePaths()); assertEquals(asList("lookatme"), options.getGlue()); assertTrue(options.isStrict()); @@ -143,7 +149,7 @@ public void overrides_options_with_system_properties_without_clobbering_non_over public void ensure_cli_glue_is_preserved_when_cucumber_options_property_defined() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--tags @foo"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "--glue", "somewhere"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("--glue", "somewhere")); assertEquals(asList("somewhere"), runtimeOptions.getGlue()); } @@ -151,7 +157,7 @@ public void ensure_cli_glue_is_preserved_when_cucumber_options_property_defined( public void clobbers_filters_from_cli_if_filters_specified_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--tags @clobber_with_this"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "--tags", "@should_be_clobbered"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("--tags", "@should_be_clobbered")); assertEquals(asList("@clobber_with_this"), runtimeOptions.getFilters()); } @@ -159,7 +165,7 @@ public void clobbers_filters_from_cli_if_filters_specified_in_cucumber_options_p public void preserves_filters_from_cli_if_filters_not_specified_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--strict"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "--tags", "@keep_this"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("--tags", "@keep_this")); assertEquals(asList("@keep_this"), runtimeOptions.getFilters()); } @@ -167,7 +173,7 @@ public void preserves_filters_from_cli_if_filters_not_specified_in_cucumber_opti public void clobbers_features_from_cli_if_features_specified_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "new newer"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "old", "older"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("old", "older")); assertEquals(asList("new", "newer"), runtimeOptions.getFeaturePaths()); } @@ -175,7 +181,7 @@ public void clobbers_features_from_cli_if_features_specified_in_cucumber_options public void preserves_features_from_cli_if_features_not_specified_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--format pretty"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "old", "older"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("old", "older")); assertEquals(asList("old", "older"), runtimeOptions.getFeaturePaths()); } @@ -183,7 +189,7 @@ public void preserves_features_from_cli_if_features_not_specified_in_cucumber_op public void clobbers_line_filters_from_cli_if_features_specified_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "new newer"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "--tags", "@keep_this", "path/file1.feature:1"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("--tags", "@keep_this", "path/file1.feature:1")); assertEquals(asList("new", "newer"), runtimeOptions.getFeaturePaths()); assertEquals(asList("@keep_this"), runtimeOptions.getFilters()); } @@ -192,14 +198,14 @@ public void clobbers_line_filters_from_cli_if_features_specified_in_cucumber_opt public void allows_removal_of_strict_in_cucumber_options_property() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--no-strict"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), "--strict"); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), asList("--strict")); assertFalse(runtimeOptions.isStrict()); } @Test public void fail_on_unsupported_options() { try { - new RuntimeOptions(new Env(), "-concreteUnsupportedOption", "somewhere", "somewhere_else"); + new RuntimeOptions(asList("-concreteUnsupportedOption", "somewhere", "somewhere_else")); fail(); } catch (CucumberException e) { assertEquals("Unknown option: -concreteUnsupportedOption", e.getMessage()); @@ -212,9 +218,9 @@ public void set_monochrome_on_color_aware_formatters() throws Exception { Formatter colorAwareFormatter = mock(Formatter.class, withSettings().extraInterfaces(ColorAware.class)); when(factory.create("progress")).thenReturn(colorAwareFormatter); - new RuntimeOptions(new Env(), factory, "--monochrome", "--format", "progress"); + new RuntimeOptions(new Env(), factory, asList("--monochrome", "--format", "progress")); - verify((ColorAware)colorAwareFormatter).setMonochrome(true); + verify((ColorAware) colorAwareFormatter).setMonochrome(true); } @Test @@ -223,15 +229,15 @@ public void set_strict_on_strict_aware_formatters() throws Exception { Formatter strictAwareFormatter = mock(Formatter.class, withSettings().extraInterfaces(StrictAware.class)); when(factory.create("junit:out/dir")).thenReturn(strictAwareFormatter); - new RuntimeOptions(new Env(), factory, "--strict", "--format", "junit:out/dir"); + new RuntimeOptions(new Env(), factory, asList("--strict", "--format", "junit:out/dir")); - verify((StrictAware)strictAwareFormatter).setStrict(true); + verify((StrictAware) strictAwareFormatter).setStrict(true); } @Test public void ensure_default_snippet_type_is_underscore() { Properties properties = new Properties(); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties)); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), Collections.emptyList()); assertEquals(SnippetType.UNDERSCORE, runtimeOptions.getSnippetType()); } @@ -239,7 +245,7 @@ public void ensure_default_snippet_type_is_underscore() { public void set_snippet_type() { Properties properties = new Properties(); properties.setProperty("cucumber.options", "--snippets camelcase"); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties)); + RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(properties), Collections.emptyList()); assertEquals(SnippetType.CAMELCASE, runtimeOptions.getSnippetType()); } diff --git a/core/src/test/java/cucumber/runtime/RuntimeTest.java b/core/src/test/java/cucumber/runtime/RuntimeTest.java index d1e734f90c..976f0a4d62 100644 --- a/core/src/test/java/cucumber/runtime/RuntimeTest.java +++ b/core/src/test/java/cucumber/runtime/RuntimeTest.java @@ -54,7 +54,7 @@ public void runs_feature_with_json_formatter() throws Exception { JSONFormatter jsonFormatter = new JSONFormatter(out); List backends = asList(mock(Backend.class)); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + RuntimeOptions runtimeOptions = new RuntimeOptions(""); Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, backends, runtimeOptions); feature.run(jsonFormatter, jsonFormatter, runtime); jsonFormatter.done(); @@ -194,7 +194,7 @@ public void should_throw_cucumer_exception_if_no_backends_are_found() throws Exc try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); new Runtime(new ClasspathResourceLoader(classLoader), classLoader, Collections.emptyList(), - new RuntimeOptions(new Env())); + new RuntimeOptions("")); fail("A CucumberException should have been thrown"); } catch (CucumberException e) { assertEquals("No backends were found. Please make sure you have a backend module on your CLASSPATH.", e.getMessage()); @@ -384,7 +384,7 @@ private Runtime createRuntime(String... runtimeArgs) { } private Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader, String... runtimeArgs) { - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(), runtimeArgs); + RuntimeOptions runtimeOptions = new RuntimeOptions(asList(runtimeArgs)); Backend backend = mock(Backend.class); Collection backends = Arrays.asList(backend); @@ -408,7 +408,7 @@ private Runtime createRuntimeWithMockedGlue(StepDefinitionMatch match, boolean i boolean isBefore, String... runtimeArgs) { ResourceLoader resourceLoader = mock(ResourceLoader.class); ClassLoader classLoader = mock(ClassLoader.class); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(), runtimeArgs); + RuntimeOptions runtimeOptions = new RuntimeOptions(asList(runtimeArgs)); Backend backend = mock(Backend.class); RuntimeGlue glue = mock(RuntimeGlue.class); mockMatch(glue, match, isAmbiguous); diff --git a/core/src/test/java/cucumber/runtime/formatter/CucumberPrettyFormatterTest.java b/core/src/test/java/cucumber/runtime/formatter/CucumberPrettyFormatterTest.java index 0ec9564742..c6241a82b0 100755 --- a/core/src/test/java/cucumber/runtime/formatter/CucumberPrettyFormatterTest.java +++ b/core/src/test/java/cucumber/runtime/formatter/CucumberPrettyFormatterTest.java @@ -1,7 +1,6 @@ package cucumber.runtime.formatter; import cucumber.runtime.Backend; -import cucumber.runtime.Env; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeGlue; import cucumber.runtime.RuntimeOptions; @@ -51,7 +50,7 @@ public void should_align_the_indentation_of_location_strings() throws IOExceptio } private String runFeatureWithPrettyFormatter(final CucumberFeature feature, final Map stepsToLocation) throws IOException { - final RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + final RuntimeOptions runtimeOptions = new RuntimeOptions(""); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader); final RuntimeGlue glue = createMockedRuntimeGlueThatMatchesTheSteps(stepsToLocation); diff --git a/core/src/test/java/cucumber/runtime/formatter/JSONPrettyFormatterTest.java b/core/src/test/java/cucumber/runtime/formatter/JSONPrettyFormatterTest.java index e2752915ae..af54eedb90 100644 --- a/core/src/test/java/cucumber/runtime/formatter/JSONPrettyFormatterTest.java +++ b/core/src/test/java/cucumber/runtime/formatter/JSONPrettyFormatterTest.java @@ -1,7 +1,6 @@ package cucumber.runtime.formatter; import cucumber.runtime.Backend; -import cucumber.runtime.Env; import cucumber.runtime.HookDefinition; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeOptions; @@ -47,7 +46,7 @@ private File runFeaturesWithJSONPrettyFormatter(final List featurePaths) args.add("json:" + report.getAbsolutePath()); args.addAll(featurePaths); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(), args.toArray(new String[args.size()])); + RuntimeOptions runtimeOptions = new RuntimeOptions(args); Backend backend = mock(Backend.class); when(backend.getSnippet(any(Step.class), any(FunctionNameGenerator.class))).thenReturn("TEST SNIPPET"); final Runtime runtime = new Runtime(resourceLoader, classLoader, asList(backend), runtimeOptions, new StopWatch.Stub(1234), null); diff --git a/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java b/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java index 2408f35632..70ef79b5ad 100644 --- a/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java +++ b/core/src/test/java/cucumber/runtime/formatter/JUnitFormatterTest.java @@ -2,7 +2,6 @@ import cucumber.api.PendingException; import cucumber.runtime.Backend; -import cucumber.runtime.Env; import cucumber.runtime.HookDefinition; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeGlue; @@ -400,7 +399,7 @@ private File runFeaturesWithJunitFormatter(final List featurePaths, bool args.add("junit:" + report.getAbsolutePath()); args.addAll(featurePaths); - RuntimeOptions runtimeOptions = new RuntimeOptions(new Env(), args.toArray(new String[args.size()])); + RuntimeOptions runtimeOptions = new RuntimeOptions(args); Backend backend = mock(Backend.class); when(backend.getSnippet(any(Step.class), any(FunctionNameGenerator.class))).thenReturn("TEST SNIPPET"); final cucumber.runtime.Runtime runtime = new Runtime(resourceLoader, classLoader, asList(backend), runtimeOptions); @@ -419,7 +418,7 @@ private String runFeatureWithJUnitFormatter(final CucumberFeature feature, final private String runFeatureWithJUnitFormatter(final CucumberFeature feature, final Map stepsToResult, final List> hooks, final long stepHookDuration) throws Throwable { - final RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + final RuntimeOptions runtimeOptions = new RuntimeOptions(Collections.emptyList()); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader); final RuntimeGlue glue = createMockedRuntimeGlueThatMatchesTheSteps(stepsToResult, hooks); diff --git a/java/src/test/java/cucumber/runtime/java/JavaStepDefinitionTest.java b/java/src/test/java/cucumber/runtime/java/JavaStepDefinitionTest.java index 5dd613a572..289cdae765 100644 --- a/java/src/test/java/cucumber/runtime/java/JavaStepDefinitionTest.java +++ b/java/src/test/java/cucumber/runtime/java/JavaStepDefinitionTest.java @@ -3,7 +3,6 @@ import cucumber.api.java.en.Given; import cucumber.runtime.AmbiguousStepDefinitionsException; import cucumber.runtime.DuplicateStepDefinitionException; -import cucumber.runtime.Env; import cucumber.runtime.Glue; import cucumber.runtime.Runtime; import cucumber.runtime.RuntimeOptions; @@ -49,7 +48,7 @@ public class JavaStepDefinitionTest { private final Defs defs = new Defs(); private final JavaBackend backend = new JavaBackend(new SingletonFactory(defs)); private final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - private final RuntimeOptions runtimeOptions = new RuntimeOptions(new Env()); + private final RuntimeOptions runtimeOptions = new RuntimeOptions(""); private final Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(backend), runtimeOptions); private final Glue glue = runtime.getGlue();