diff --git a/History.md b/History.md index 96ac992e57..c5cf37935c 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,6 @@ ## [Git master](https://github.com/cucumber/cucumber-jvm/compare/v1.0.3...master) +* [Core] Ability to specify line numbers: `@Cucumber.Options(features = "my/nice.feature:2:10")` ([#234](https://github.com/cucumber/cucumber-jvm/issues/234) Aslak Hellesøy) * [WebDriver] Improved example that shows how to reuse a driver for the entire JVM. (Aslak Hellesøy) * [Core] Allow custom @XStreamConverter to be used on regular arguments - not just table arguments. (Aslak Hellesøy) * [Groovy] fixed & simplified groovy step snippets ([#303](https://github.com/cucumber/cucumber-jvm/pull/303) Martin Hauner) diff --git a/core/src/main/java/cucumber/runtime/RuntimeOptions.java b/core/src/main/java/cucumber/runtime/RuntimeOptions.java index fd0f09bc3b..cdcd6d9f32 100644 --- a/core/src/main/java/cucumber/runtime/RuntimeOptions.java +++ b/core/src/main/java/cucumber/runtime/RuntimeOptions.java @@ -28,7 +28,7 @@ public class RuntimeOptions { public File dotCucumber; public boolean dryRun; public boolean strict = false; - public List tags = new ArrayList(); + public List filters = new ArrayList(); public List formatters = new ArrayList(); public List featurePaths = new ArrayList(); private boolean monochrome = false; @@ -63,7 +63,7 @@ private void parse(ArrayList args) { String gluePath = args.remove(0); glue.add(gluePath); } else if (arg.equals("--tags") || arg.equals("-t")) { - tags.add(args.remove(0)); + filters.add(args.remove(0)); } else if (arg.equals("--format") || arg.equals("-f")) { formatters.add(formatterConverter.convert(args.remove(0))); } else if (arg.equals("--dotcucumber")) { @@ -75,14 +75,15 @@ private void parse(ArrayList args) { } else if (arg.equals("--monochrome") || arg.equals("-m")) { monochrome = true; } else { - // TODO: Use PathWithLines and add line filter if any - featurePaths.add(arg); + PathWithLines pathWithLines = new PathWithLines(arg); + featurePaths.add(pathWithLines.path); + filters.addAll(pathWithLines.lines); } } } public List cucumberFeatures(ResourceLoader resourceLoader) { - return load(resourceLoader, featurePaths, filters()); + return load(resourceLoader, featurePaths, filters); } public Formatter formatter(ClassLoader classLoader) { @@ -110,11 +111,4 @@ public Object invoke(Object target, Method method, Object[] args) throws Throwab } }); } - - private List filters() { - List filters = new ArrayList(); - filters.addAll(tags); - // TODO: Add lines and patterns (names) - return filters; - } } diff --git a/examples/java-helloworld/pom.xml b/examples/java-helloworld/pom.xml index a532e03a35..d9fe09b4ed 100644 --- a/examples/java-helloworld/pom.xml +++ b/examples/java-helloworld/pom.xml @@ -4,7 +4,7 @@ info.cukes java-helloworld - 1.0.3 + 1.0.4-SNAPSHOT jar Examples: Java Hello World @@ -27,13 +27,13 @@ info.cukes cucumber-java - 1.0.2 + 1.0.4-SNAPSHOT test info.cukes cucumber-junit - 1.0.2 + 1.0.4-SNAPSHOT test diff --git a/junit/src/main/java/cucumber/junit/Cucumber.java b/junit/src/main/java/cucumber/junit/Cucumber.java index 8ed50a4330..8badea66c0 100644 --- a/junit/src/main/java/cucumber/junit/Cucumber.java +++ b/junit/src/main/java/cucumber/junit/Cucumber.java @@ -56,8 +56,7 @@ public Cucumber(Class clazz) throws InitializationError, IOException { RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); runtime = new Runtime(resourceLoader, classLoader, runtimeOptions); - jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader) - , runtimeOptions.strict); + jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader), runtimeOptions.strict); addChildren(runtimeOptions.cucumberFeatures(resourceLoader)); } @@ -120,7 +119,8 @@ private void addChildren(List cucumberFeatures) throws Initiali boolean dryRun() default false; /** - * Scenarios fail if + * Scenarios fail if + * * @return */ boolean strict() default false; @@ -136,7 +136,7 @@ private void addChildren(List cucumberFeatures) throws Initiali String[] glue() default {}; /** - * @return what tags in the feature should be executed + * @return what tags in the features should be executed */ String[] tags() default {}; diff --git a/picocontainer/src/test/java/cucumber/runtime/java/picocontainer/RunCukesTest.java b/picocontainer/src/test/java/cucumber/runtime/java/picocontainer/RunCukesTest.java index dc5dc43073..0f7f6624b0 100644 --- a/picocontainer/src/test/java/cucumber/runtime/java/picocontainer/RunCukesTest.java +++ b/picocontainer/src/test/java/cucumber/runtime/java/picocontainer/RunCukesTest.java @@ -4,5 +4,6 @@ import org.junit.runner.RunWith; @RunWith(Cucumber.class) +//@Cucumber.Options(features = "cucumber/runtime/java/picocontainer/dates.feature:2:10") public class RunCukesTest { } diff --git a/picocontainer/src/test/resources/.cucumber/stepdefs.json b/picocontainer/src/test/resources/.cucumber/stepdefs.json index 8f5720a68d..3ecb0277f4 100644 --- a/picocontainer/src/test/resources/.cucumber/stepdefs.json +++ b/picocontainer/src/test/resources/.cucumber/stepdefs.json @@ -124,6 +124,15 @@ } ] }, + { + "name": "the date should be Mar 1 2013", + "args": [ + { + "offset": 19, + "val": "Mar 1 2013" + } + ] + }, { "name": "the date should be Oct 25 2011", "args": [ @@ -147,6 +156,15 @@ "val": "2012-03-01T06:54:14" } ] + }, + { + "name": "the iso calendar is 2013-03-01T06:54:14", + "args": [ + { + "offset": 20, + "val": "2013-03-01T06:54:14" + } + ] } ] }, diff --git a/picocontainer/src/test/resources/cucumber/runtime/java/picocontainer/dates.feature b/picocontainer/src/test/resources/cucumber/runtime/java/picocontainer/dates.feature index f12ce26f5d..c9dc0a3d87 100644 --- a/picocontainer/src/test/resources/cucumber/runtime/java/picocontainer/dates.feature +++ b/picocontainer/src/test/resources/cucumber/runtime/java/picocontainer/dates.feature @@ -10,3 +10,7 @@ Feature: Dates Scenario: An ISO 8601 date as Calendar Given the iso calendar is 2012-03-01T06:54:14 Then the date should be Mar 1 2012 + + Scenario: Another ISO 8601 date as Calendar + Given the iso calendar is 2013-03-01T06:54:14 + Then the date should be Mar 1 2013