Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cucumber/cucumber-jvm
...
head fork: cucumber/cucumber-jvm
Checking mergeability… Don't worry, you can still create the pull request.
  • 13 commits
  • 53 files changed
  • 0 commit comments
  • 1 contributor
Showing with 287 additions and 97 deletions.
  1. +8 −1 History.md
  2. +5 −5 README.md
  3. +1 −1  clojure/pom.xml
  4. +2 −3 clojure/src/main/clj/cucumber/runtime/clj.clj
  5. +5 −0 clojure/src/main/java/cucumber/runtime/clojure/Dummy.java
  6. +2 −1  clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippet.java
  7. +4 −2 clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippetTest.java
  8. +4 −0 clojure/src/test/resources/cucumber/runtime/clojure/stepdefs.clj
  9. +1 −1  core/pom.xml
  10. +9 −7 core/src/main/java/cucumber/formatter/FormatterConverter.java
  11. +60 −0 core/src/main/java/cucumber/formatter/NullFormatter.java
  12. +5 −0 core/src/main/java/cucumber/runtime/PendingException.java
  13. +1 −1  core/src/main/java/cucumber/runtime/Runtime.java
  14. +29 −1 core/src/main/java/cucumber/runtime/snippets/Snippet.java
  15. +0 −12 core/src/main/java/cucumber/runtime/snippets/SnippetGenerator.java
  16. +12 −0 core/src/test/java/cucumber/formatter/FormatterConverterTest.java
  17. +1 −1  examples/groovy-calculator/pom.xml
  18. +1 −1  examples/java-calculator/pom.xml
  19. +1 −1  examples/java-helloworld/build.xml
  20. +3 −3 examples/java-helloworld/pom.xml
  21. +1 −0  examples/java-helloworld/src/test/java/cucumber/examples/java/helloworld/RunCukesTest.java
  22. +1 −1  examples/java-webbit-websockets-selenium/pom.xml
  23. +1 −1  examples/scala-calculator/pom.xml
  24. +1 −1  groovy/pom.xml
  25. +1 −0  groovy/src/main/java/cucumber/runtime/groovy/GroovySnippet.java
  26. +9 −0 groovy/src/test/groovy/cucumber/runtime/groovy/GroovySnippetTest.java
  27. +1 −1  guice/pom.xml
  28. +1 −1  ioke/pom.xml
  29. +1 −1  java/pom.xml
  30. +0 −12 java/src/main/java/cucumber/annotation/Pending.java
  31. +2 −1  java/src/main/java/cucumber/runtime/java/JavaSnippet.java
  32. +0 −5 java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java
  33. +21 −0 java/src/test/java/cucumber/runtime/java/JavaSnippetTest.java
  34. +1 −1  jruby/pom.xml
  35. +1 −1  junit/pom.xml
  36. +19 −16 junit/src/main/java/cucumber/junit/RuntimeOptionsFactory.java
  37. +1 −1  jython/pom.xml
  38. +12 −2 jython/src/main/java/cucumber/runtime/jython/JythonBackend.java
  39. +3 −1 jython/src/main/java/cucumber/runtime/jython/JythonSnippet.java
  40. +2 −0  jython/src/main/resources/cucumber/runtime/jython/dsl.py
  41. +29 −0 jython/src/test/java/cucumber/runtime/jython/JythonSnippetTest.java
  42. +1 −1  openejb/pom.xml
  43. +1 −1  picocontainer/pom.xml
  44. +1 −1  pom.xml
  45. +1 −1  rhino/pom.xml
  46. +1 −0  rhino/src/main/java/cucumber/runtime/javascript/JavaScriptSnippet.java
  47. +14 −1 rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java
  48. +1 −2  rhino/src/main/resources/cucumber/runtime/rhino/dsl.js
  49. +1 −0  rhino/src/test/java/cucumber/runtime/javascript/JavaScriptSnippetTest.java
  50. +1 −1  scala/pom.xml
  51. +1 −0  scala/src/main/scala/cucumber/runtime/ScalaSnippet.scala
  52. +1 −1  spring/pom.xml
  53. +1 −1  weld/pom.xml
View
9 History.md
@@ -1,4 +1,11 @@
-## [Git master](https://github.com/cucumber/cucumber-jvm/compare/v1.0.0.RC22...master)
+## [1.0.0.RC24](https://github.com/cucumber/cucumber-jvm/compare/v1.0.0.RC23...v1.0.0.RC24)
+
+* [Core] Understandable error message if a formatter needs output location. ([#148](https://github.com/cucumber/cucumber-jvm/issues/148), [#232](https://github.com/cucumber/cucumber-jvm/issues/232), [#269](https://github.com/cucumber/cucumber-jvm/issues/269) Aslak Hellesøy)
+* [JUnit] Running with JUnit uses a null formatter by default (instead of a progress formatter). (Aslak Hellesøy)
+* [Clojure] Fix release artifacts so cucumber-clojure can be released. ([#270](https://github.com/cucumber/cucumber-jvm/issues/270) Aslak Hellesøy)
+* [Java] The @Pending annotation no longer exists. Throw a PendingException instead ([#271](https://github.com/cucumber/cucumber-jvm/issues/271) Aslak Hellesøy)
+
+## [1.0.0.RC23](https://github.com/cucumber/cucumber-jvm/compare/v1.0.0.RC22...v1.0.0.RC23)
* [JUnit] CucumberException when running Cucumber with Jacoco code coverage ([#258](https://github.com/cucumber/cucumber-jvm/issues/258) Jan Stamer, Aslak Hellesøy)
* [Scala] Scala Javadoc problems with build ([#231](https://github.com/cucumber/cucumber-jvm/issues/231) Aslak Hellesøy)
View
10 README.md
@@ -47,13 +47,13 @@ in your [POM](http://maven.apache.org/pom.html):
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -71,7 +71,7 @@ There are more jars available - add the ones you need. (TODO: A guide on how to
Add a [dependency](http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html) in your [ivy.xml](http://ant.apache.org/ivy/history/latest-milestone/ivyfile.html):
```xml
- <dependency org="info.cukes" name="cucumber-core" rev="1.0.0.RC23"/>
+ <dependency org="info.cukes" name="cucumber-core" rev="1.0.0.RC24"/>
```
Since the artifacts are released to Maven Central, the default Ivy configuration should pull them down automatically.
@@ -92,7 +92,7 @@ If you are adventurous, check out the examples, read the code and ask specific q
### API Docs
-* http://cukes.info/cucumber/jvm/api/1.0.0.RC23
+* http://cukes.info/cucumber/jvm/api/1.0.0.RC24
## Examples
@@ -225,6 +225,6 @@ Then release everything:
```
mvn release:clean
-mvn --batch-mode -P release-sign-artifacts release:prepare -DautoVersionSubmodules=true -DdevelopmentVersion=1.0.0.RC24-SNAPSHOT
+mvn --batch-mode -P release-sign-artifacts release:prepare -DautoVersionSubmodules=true -DdevelopmentVersion=1.0.0.RC25-SNAPSHOT
mvn -P release-sign-artifacts release:perform
```
View
2  clojure/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-clojure</artifactId>
View
5 clojure/src/main/clj/cucumber/runtime/clj.clj
@@ -23,7 +23,8 @@
(template [_]
(str
"({0} #\"{1}\" [{3}]\n"
- " (comment {4} ))\n"))
+ " (comment {4} )\n"
+ " (throw (cucumber.runtime.PendingException.)))\n"))
(arguments [_ argumentTypes]
(SnippetGenerator/untypedArguments argumentTypes))
(namedGroupStart [_] nil)
@@ -113,8 +114,6 @@
(.eval te tags))
(getOrder [hd] 0)))))
-;; TODO: before and after hooks
-
(defmacro step-macros [& names]
(cons 'do
(for [name names]
View
5 clojure/src/main/java/cucumber/runtime/clojure/Dummy.java
@@ -0,0 +1,5 @@
+package cucumber.runtime.clojure;
+
+// Nothing to see here, just a workaround for https://github.com/cucumber/cucumber-jvm/issues/270
+public class Dummy {
+}
View
3  clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippet.java
@@ -14,7 +14,8 @@
@Override
public String template() {
return "({0} #\"{1}\" [{3}]\n" +
- " (comment {4} ))\n";
+ " (comment {4} )\n" +
+ " (throw (cucumber.runtime.PendingException.)))\n";
}
@Override
View
6 clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippetTest.java
@@ -21,7 +21,8 @@ public void generatesPlainSnippet() {
String snippet = new SnippetGenerator(new ClojureSnippet()).getSnippet(step);
String expected = "" +
"(Given #\"^I have (\\d+) cukes in my \"([^\"]*)\" belly$\" [arg1, arg2]\n" +
- " (comment Express the Regexp above with the code you wish you had ))\n";
+ " (comment Express the Regexp above with the code you wish you had )\n" +
+ " (throw (cucumber.runtime.PendingException.)))\n";
assertEquals(expected, snippet);
}
@@ -32,7 +33,8 @@ public void generatesSnippetWithDataTable() {
String snippet = new SnippetGenerator(new ClojureSnippet()).getSnippet(step);
String expected = "" +
"(Given #\"^I have:$\" [arg1]\n" +
- " (comment Express the Regexp above with the code you wish you had ))\n";
+ " (comment Express the Regexp above with the code you wish you had )\n" +
+ " (throw (cucumber.runtime.PendingException.)))\n";
assertEquals(expected, snippet);
}
}
View
4 clojure/src/test/resources/cucumber/runtime/clojure/stepdefs.clj
@@ -23,3 +23,7 @@
(When #"^I add (.*)$" [liquid]
(assert (= "milk" liquid)))
+
+(Given #"^(\d+) unimplemented step$" [arg1]
+ (comment Express the Regexp above with the code you wish you had )
+ (throw (cucumber.runtime.PendingException.)))
View
2  core/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-core</artifactId>
View
16 core/src/main/java/cucumber/formatter/FormatterConverter.java
@@ -21,6 +21,7 @@
private Class[] CTOR_ARGS = new Class[]{Appendable.class, File.class};
private static final Map<String, Class<? extends Formatter>> FORMATTER_CLASSES = new HashMap<String, Class<? extends Formatter>>() {{
+ put("null", NullFormatter.class);
put("junit", JUnitFormatter.class);
put("html", HTMLFormatter.class);
put("pretty", CucumberPrettyFormatter.class);
@@ -44,19 +45,17 @@ public Formatter convert(String formatterString) {
}
Class<? extends Formatter> formatterClass = formatterClass(formatterName);
try {
- return instantiate(formatterClass, ctorArg);
+ return instantiate(formatterString, formatterClass, ctorArg);
} catch (IOException e) {
throw new CucumberException(e);
}
}
- private Formatter instantiate(Class<? extends Formatter> formatterClass, Object ctorArg) throws IOException {
- Constructor<? extends Formatter> constructor;
-
+ private Formatter instantiate(String formatterString, Class<? extends Formatter> formatterClass, Object ctorArg) throws IOException {
for (Class ctorArgClass : CTOR_ARGS) {
- constructor = findConstructor(formatterClass, ctorArgClass);
+ Constructor<? extends Formatter> constructor = findConstructor(formatterClass, ctorArgClass);
if (constructor != null) {
- ctorArg = convert(ctorArg, ctorArgClass);
+ ctorArg = convertOrNull(ctorArg, ctorArgClass);
if (ctorArg != null) {
try {
return constructor.newInstance(ctorArg);
@@ -70,10 +69,13 @@ private Formatter instantiate(Class<? extends Formatter> formatterClass, Object
}
}
}
+ if (ctorArg == null) {
+ throw new CucumberException(String.format("You must supply an output argument to %s. Like so: %s:output", formatterString, formatterString));
+ }
throw new CucumberException(String.format("%s must have a single-argument constructor that takes one of the following: %s", formatterClass, asList(CTOR_ARGS)));
}
- private Object convert(Object ctorArg, Class ctorArgClass) throws IOException {
+ private Object convertOrNull(Object ctorArg, Class ctorArgClass) throws IOException {
if (ctorArgClass.isAssignableFrom(ctorArg.getClass())) {
return ctorArg;
}
View
60 core/src/main/java/cucumber/formatter/NullFormatter.java
@@ -0,0 +1,60 @@
+package cucumber.formatter;
+
+import gherkin.formatter.Formatter;
+import gherkin.formatter.model.Background;
+import gherkin.formatter.model.Examples;
+import gherkin.formatter.model.Feature;
+import gherkin.formatter.model.Scenario;
+import gherkin.formatter.model.ScenarioOutline;
+import gherkin.formatter.model.Step;
+
+import java.util.List;
+
+public class NullFormatter implements Formatter {
+ public NullFormatter(Appendable ignore) {
+ }
+
+ @Override
+ public void uri(String uri) {
+ }
+
+ @Override
+ public void feature(Feature feature) {
+ }
+
+ @Override
+ public void background(Background background) {
+ }
+
+ @Override
+ public void scenario(Scenario scenario) {
+ }
+
+ @Override
+ public void scenarioOutline(ScenarioOutline scenarioOutline) {
+ }
+
+ @Override
+ public void examples(Examples examples) {
+ }
+
+ @Override
+ public void step(Step step) {
+ }
+
+ @Override
+ public void eof() {
+ }
+
+ @Override
+ public void syntaxError(String state, String event, List<String> legalEvents, String uri, int line) {
+ }
+
+ @Override
+ public void done() {
+ }
+
+ @Override
+ public void close() {
+ }
+}
View
5 core/src/main/java/cucumber/runtime/PendingException.java
@@ -1,6 +1,11 @@
package cucumber.runtime;
+// We're deliberately not extending CucumberException (which is used to signal fatal errors)
public class PendingException extends RuntimeException {
+ public PendingException() {
+ this("TODO: implement me");
+ }
+
public PendingException(String message) {
super(message);
}
View
2  core/src/main/java/cucumber/runtime/Runtime.java
@@ -223,7 +223,7 @@ public void runStep(String uri, Step step, Reporter reporter, I18n i18n) {
match.runStep(i18n);
} catch (Throwable t) {
error = t;
- status = Result.FAILED;
+ status = (t instanceof PendingException) ? "pending" : Result.FAILED;
addError(t);
skipNextStep = true;
} finally {
View
30 core/src/main/java/cucumber/runtime/snippets/Snippet.java
@@ -3,20 +3,48 @@
import java.util.List;
public interface Snippet {
+ /**
+ * @return a {@link java.text.MessageFormat} template used to generate a snippet. The template can access the following variables:
+ *
+ * <ul>
+ * <li>{0} : Step Keyword</li>
+ * <li>{1} : Value of {@link #escapePattern(String)}</li>
+ * <li>{2} : Function name</li>
+ * <li>{3} : Value of {@link #arguments(java.util.List)}</li>
+ * <li>{4} : Regexp hint comment</li>
+ * <li>{5} : value of {@link #tableHint()} if the step has a table</li>
+ * </ul>
+ */
String template();
+ /**
+ * @return a hint about alternative ways to declare a table argument
+ */
String tableHint();
+ /**
+ * @param argumentTypes the types the snippet's argument should accept
+ * @return a string representation of the arguments
+ */
String arguments(List<Class<?>> argumentTypes);
/**
* Langauges that don't support named capture groups should return null.
*
- * @return the start of a named group
+ * @return the start of a named capture group
*/
String namedGroupStart();
+ /**
+ * Langauges that don't support named capture groups should return null.
+ *
+ * @return the end of a named capture group
+ */
String namedGroupEnd();
+ /**
+ * @param pattern the computed pattern that will match an undefined step
+ * @return an escaped representation of the pattern, if escaping is necessary.
+ */
String escapePattern(String pattern);
}
View
12 core/src/main/java/cucumber/runtime/snippets/SnippetGenerator.java
@@ -10,18 +10,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-/**
- * Base class for generating snippets.
- * <p/>
- * Subclasses can access common values:
- * <ul>
- * <li>{0} : Keyword</li>
- * <li>{1} : Regexp</li>
- * <li>{2} : Function name</li>
- * <li>{3} : Arguments</li>
- * <li>{4} : Hint comment</li>
- * </ul>
- */
public final class SnippetGenerator {
private static final ArgumentPattern[] DEFAULT_ARGUMENT_PATTERNS = new ArgumentPattern[]{
new ArgumentPattern(Pattern.compile("\"([^\"]*)\""), String.class),
View
12 core/src/test/java/cucumber/formatter/FormatterConverterTest.java
@@ -1,5 +1,6 @@
package cucumber.formatter;
+import cucumber.runtime.CucumberException;
import gherkin.formatter.Formatter;
import org.junit.Test;
@@ -8,6 +9,7 @@
import static cucumber.formatter.TempDir.createTempDirectory;
import static cucumber.formatter.TempDir.createTempFile;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
public class FormatterConverterTest {
private FormatterConverter fc = new FormatterConverter();
@@ -25,6 +27,16 @@ public void instantiates_html_formatter_with_dir_arg() throws IOException {
}
@Test
+ public void fails_to_instantiate_html_formatter_without_dir_arg() throws IOException {
+ try {
+ fc.convert("html");
+ fail();
+ } catch(CucumberException e) {
+ assertEquals("You must supply an output argument to html. Like so: html:output", e.getMessage());
+ }
+ }
+
+ @Test
public void instantiates_pretty_formatter_with_file_arg() throws IOException {
Formatter formatter = fc.convert("pretty:" + createTempFile().getAbsolutePath());
assertEquals(CucumberPrettyFormatter.class, formatter.getClass());
View
2  examples/groovy-calculator/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>groovy-calculator</artifactId>
View
2  examples/java-calculator/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>java-calculator</artifactId>
View
2  examples/java-helloworld/build.xml
@@ -1,6 +1,6 @@
<project name="java-helloworld" basedir="." default="runcukes">
<property name="repo" value="https://oss.sonatype.org/content/repositories/releases"/>
- <property name="cucumber.version" value="1.0.0.RC21"/>
+ <property name="cucumber.version" value="1.0.0.RC23"/>
<property name="gherkin.version" value="2.9.1"/>
<target name="download">
View
6 examples/java-helloworld/pom.xml
@@ -3,7 +3,7 @@
<groupId>info.cukes</groupId>
<artifactId>java-helloworld</artifactId>
- <version>1.0.0.RC21</version>
+ <version>1.0.0.RC23</version>
<packaging>jar</packaging>
<name>Examples: Java Hello World</name>
@@ -11,13 +11,13 @@
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
- <version>1.0.0.RC21</version>
+ <version>1.0.0.RC23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
- <version>1.0.0.RC21</version>
+ <version>1.0.0.RC23</version>
<scope>test</scope>
</dependency>
<dependency>
View
1  examples/java-helloworld/src/test/java/cucumber/examples/java/helloworld/RunCukesTest.java
@@ -4,5 +4,6 @@
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
+@Cucumber.Options(format = {"pretty", "html:target/cucumber"})
public class RunCukesTest {
}
View
2  examples/java-webbit-websockets-selenium/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>java-webbit-websockets-selenium</artifactId>
View
2  examples/scala-calculator/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>scala-calculator</artifactId>
View
2  groovy/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-groovy</artifactId>
View
1  groovy/src/main/java/cucumber/runtime/groovy/GroovySnippet.java
@@ -9,6 +9,7 @@
public String template() {
return "{0}(~\"{1}\") '{' {3}->\n" +
" // {4}\n" +
+ " throw new PendingException()\n" +
"'}'\n";
}
View
9 groovy/src/test/groovy/cucumber/runtime/groovy/GroovySnippetTest.java
@@ -22,6 +22,7 @@ public void generatesPlainSnippet() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\") { int arg1, String arg2 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
}
@@ -31,6 +32,7 @@ public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Excep
String expected = "" +
"Given(~\"^before (\\d+) after$\") { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
String snippet = snippetFor("before 5 after");
assertEquals(expected, snippet);
@@ -41,6 +43,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars(
String expected = "" +
"Given(~\"^I have (\\d+) cukes in: my \\\"([^\\\"]*)\\\" red-belly!$\") { int arg1, String arg2 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("I have 4 cukes in: my \"big\" red-belly!"));
}
@@ -51,6 +54,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParamet
String expected = "" +
"Given(~\"^the DI system receives a message saying \\\"([^\\\"]*)\\\"$\") { String arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("the DI system receives a message saying \"{ dataIngestion: { feeds: [ feed: { merchantId: 666, feedId: 1, feedFileLocation: feed.csv } ] }\""));
}
@@ -60,6 +64,7 @@ public void generatesSnippetWithEscapedDollarSigns() {
String expected = "" +
"Given(~\"^I have \\$(\\d+)$\") { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("I have $5"));
}
@@ -69,6 +74,7 @@ public void generatesSnippetWithEscapedParentheses() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes \\(maybe more\\)$\") { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("I have 5 cukes (maybe more)"));
}
@@ -78,6 +84,7 @@ public void generatesSnippetWithEscapedBrackets() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes \\[maybe more\\]$\") { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetFor("I have 5 cukes [maybe more]"));
}
@@ -87,6 +94,7 @@ public void generatesSnippetWithDocString() {
String expected = "" +
"Given(~\"^I have:$\") { String arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
assertEquals(expected, snippetForDocString("I have:", new DocString("text/plain", "hello", 1)));
}
@@ -96,6 +104,7 @@ public void generatesSnippetWithDataTable() {
String expected = "" +
"Given(~\"^I have:$\") { DataTable arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException()\n" +
"}\n";
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
assertEquals(expected, snippetForDataTable("I have:", dataTable));
View
2  guice/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-guice</artifactId>
View
2  ioke/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-ioke</artifactId>
View
2  java/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-java</artifactId>
View
12 java/src/main/java/cucumber/annotation/Pending.java
@@ -1,12 +0,0 @@
-package cucumber.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Pending {
- String value() default "TODO";
-}
View
3  java/src/main/java/cucumber/runtime/java/JavaSnippet.java
@@ -24,7 +24,8 @@ public String template() {
return "@{0}(\"{1}\")\n" +
"public void {2}({3}) '{'\n" +
" // {4}\n" +
- "{5}'}'\n";
+ "{5} throw new PendingException();\n" +
+ "'}'\n";
}
@Override
View
5 java/src/main/java/cucumber/runtime/java/JavaStepDefinition.java
@@ -1,10 +1,8 @@
package cucumber.runtime.java;
-import cucumber.annotation.Pending;
import cucumber.runtime.CucumberException;
import cucumber.runtime.JdkPatternArgumentMatcher;
import cucumber.runtime.ParameterType;
-import cucumber.runtime.PendingException;
import cucumber.runtime.StepDefinition;
import gherkin.I18n;
import gherkin.formatter.Argument;
@@ -33,9 +31,6 @@ public JavaStepDefinition(Method method, Pattern pattern, ObjectFactory objectFa
}
public void execute(I18n i18n, Object[] args) throws Throwable {
- if (method.isAnnotationPresent(Pending.class)) {
- throw new PendingException(method.getAnnotation(Pending.class).value());
- }
Class<?> clazz = method.getDeclaringClass();
Object target = objectFactory.getInstance(clazz);
try {
View
21 java/src/test/java/cucumber/runtime/java/JavaSnippetTest.java
@@ -5,6 +5,7 @@
import gherkin.formatter.model.DataTableRow;
import gherkin.formatter.model.DocString;
import gherkin.formatter.model.Step;
+import org.junit.Ignore;
import org.junit.Test;
import java.util.Collections;
@@ -23,6 +24,7 @@ public void generatesPlainSnippet() {
"@Given(\"^I have (\\\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\")\n" +
"public void I_have_cukes_in_my_belly(int arg1, String arg2) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
}
@@ -33,6 +35,7 @@ public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Excep
"@Given(\"^before (\\\\d+) after$\")\n" +
"public void before_after(int arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
String snippet = snippetFor("before 5 after");
assertEquals(expected, snippet);
@@ -44,6 +47,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars(
"@Given(\"^I have (\\\\d+) cukes in: my \\\"([^\\\"]*)\\\" red-belly!$\")\n" +
"public void I_have_cukes_in_my_red_belly(int arg1, String arg2) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("I have 4 cukes in: my \"big\" red-belly!"));
}
@@ -55,6 +59,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParamet
"@Given(\"^the DI system receives a message saying \\\"([^\\\"]*)\\\"$\")\n" +
"public void the_DI_system_receives_a_message_saying(String arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("the DI system receives a message saying \"{ dataIngestion: { feeds: [ feed: { merchantId: 666, feedId: 1, feedFileLocation: feed.csv } ] }\""));
}
@@ -65,6 +70,7 @@ public void generatesSnippetWithEscapedDollarSigns() {
"@Given(\"^I have \\\\$(\\\\d+)$\")\n" +
"public void I_have_$(int arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("I have $5"));
}
@@ -75,6 +81,7 @@ public void generatesSnippetWithEscapedParentheses() {
"@Given(\"^I have (\\\\d+) cukes \\\\(maybe more\\\\)$\")\n" +
"public void I_have_cukes_maybe_more(int arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("I have 5 cukes (maybe more)"));
}
@@ -85,6 +92,7 @@ public void generatesSnippetWithEscapedBrackets() {
"@Given(\"^I have (\\\\d+) cukes \\\\[maybe more\\\\]$\")\n" +
"public void I_have_cukes_maybe_more(int arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetFor("I have 5 cukes [maybe more]"));
}
@@ -95,17 +103,30 @@ public void generatesSnippetWithDocString() {
"@Given(\"^I have:$\")\n" +
"public void I_have(String arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new PendingException();\n" +
"}\n";
assertEquals(expected, snippetForDocString("I have:", new DocString("text/plain", "hello", 1)));
}
@Test
+ @Ignore
+ public void recognisesWordWithNumbers() {
+ String expected = "" +
+ "@Given(\"^Then it responds ([^\\\"]*)$\")\n" +
+ "public void Then_it_responds_UTF(int arg1) {\n" +
+ " // Express the Regexp above with the code you wish you had\n" +
+ "}\n";
+ assertEquals(expected, snippetFor("Then it responds UTF-8"));
+ }
+
+ @Test
public void generatesSnippetWithDataTable() {
String expected = "" +
"@Given(\"^I have:$\")\n" +
"public void I_have(DataTable arg1) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" // For automatic conversion, change DataTable to List<YourType>\n" +
+ " throw new PendingException();\n" +
"}\n";
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
assertEquals(expected, snippetForDataTable("I have:", dataTable));
View
2  jruby/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-jruby</artifactId>
View
2  junit/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-junit</artifactId>
View
35 junit/src/main/java/cucumber/junit/RuntimeOptionsFactory.java
@@ -17,19 +17,19 @@ public RuntimeOptionsFactory(Class clazz) {
public RuntimeOptions create() {
List<String> args = new ArrayList<String>();
- Cucumber.Options cucumberOptions = getFeatureAnnotation(clazz);
+ Cucumber.Options options = getOptions(clazz);
- addDryRun(cucumberOptions, args);
- addGlue(cucumberOptions, clazz, args);
- addFeatures(cucumberOptions, clazz, args);
- addTags(cucumberOptions, args);
- addFormats(cucumberOptions, args);
+ addDryRun(options, args);
+ addGlue(options, clazz, args);
+ addTags(options, args);
+ addFormats(options, args);
+ addFeatures(options, clazz, args);
return new RuntimeOptions(args.toArray(new String[args.size()]));
}
- private Cucumber.Options getFeatureAnnotation(Class<?> clazz) {
+ private Cucumber.Options getOptions(Class<?> clazz) {
return clazz.getAnnotation(Cucumber.Options.class);
}
@@ -53,14 +53,6 @@ private void addGlue(Cucumber.Options options, Class clazz, List<String> args) {
}
}
- private void addFeatures(Cucumber.Options options, Class clazz, List<String> args) {
- if (options != null && options.features().length != 0) {
- Collections.addAll(args, options.features());
- } else {
- args.add(packagePath(clazz));
- }
- }
-
private void addTags(Cucumber.Options options, List<String> args) {
if (options != null) {
for (String tags : options.tags()) {
@@ -71,11 +63,22 @@ private void addTags(Cucumber.Options options, List<String> args) {
}
private void addFormats(Cucumber.Options options, List<String> args) {
- if (options != null) {
+ if (options != null && options.format().length != 0) {
for (String format : options.format()) {
args.add("--format");
args.add(format);
}
+ } else {
+ args.add("--format");
+ args.add("null");
+ }
+ }
+
+ private void addFeatures(Cucumber.Options options, Class clazz, List<String> args) {
+ if (options != null && options.features().length != 0) {
+ Collections.addAll(args, options.features());
+ } else {
+ args.add(packagePath(clazz));
}
}
}
View
2  jython/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-jython</artifactId>
View
14 jython/src/main/java/cucumber/runtime/jython/JythonBackend.java
@@ -8,6 +8,7 @@
import cucumber.runtime.UnreportedStepExecutor;
import cucumber.runtime.snippets.SnippetGenerator;
import gherkin.formatter.model.Step;
+import org.python.core.PyException;
import org.python.core.PyInstance;
import org.python.core.PyObject;
import org.python.core.PyString;
@@ -77,12 +78,21 @@ public void registerStepdef(PyInstance stepdef, int arity) {
glue.addStepDefinition(new JythonStepDefinition(this, stepdef, arity));
}
- public void execute(PyInstance stepdef, Object[] args) {
+ public void execute(PyInstance stepdef, Object[] args) throws Throwable {
PyObject[] pyArgs = new PyObject[args.length + 1];
pyArgs[0] = pyWorld;
for (int i = 0; i < args.length; i++) {
pyArgs[i + 1] = new PyString((String) args[i]);
}
- stepdef.invoke("execute", pyArgs);
+ try {
+ stepdef.invoke("execute", pyArgs);
+ } catch (PyException t) {
+ Object unwrapped = t.value.__tojava__(Object.class);
+ if (unwrapped instanceof Throwable) {
+ throw (Throwable) unwrapped;
+ } else {
+ throw t.getCause() == null ? t : t.getCause();
+ }
+ }
}
}
View
4 jython/src/main/java/cucumber/runtime/jython/JythonSnippet.java
@@ -12,7 +12,9 @@
public String template() {
return "@{0}(''{1}'')\n" +
"def {2}({3}):\n" +
- " # {4}\n";
+ " # {4}\n" +
+ " raise(PendingException())\n" +
+ "";
}
@Override
View
2  jython/src/main/resources/cucumber/runtime/jython/dsl.py
@@ -1,5 +1,7 @@
import re
from gherkin.formatter import Argument
+from cucumber.runtime import PendingException
+
class I18NKeywordTemplate(object):
def __init__(self, regexp):
self.regexp = regexp
View
29 jython/src/test/java/cucumber/runtime/jython/JythonSnippetTest.java
@@ -0,0 +1,29 @@
+package cucumber.runtime.jython;
+
+import cucumber.runtime.snippets.SnippetGenerator;
+import gherkin.formatter.model.Comment;
+import gherkin.formatter.model.Step;
+import org.junit.Test;
+
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+public class JythonSnippetTest {
+
+ @Test
+ public void generatesPlainSnippet() {
+ String expected = "" +
+ "@Given('^I have (\\d+) cukes in my \"([^\"]*)\" belly$')\n" +
+ "def I_have_cukes_in_my_belly(arg1, arg2):\n" +
+ " # Express the Regexp above with the code you wish you had\n" +
+ " raise(PendingException())\n" +
+ "";
+ assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
+ }
+
+ private String snippetFor(String name) {
+ Step step = new Step(Collections.<Comment>emptyList(), "Given ", name, 0, null, null);
+ return new SnippetGenerator(new JythonSnippet()).getSnippet(step);
+ }
+}
View
2  openejb/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-openejb</artifactId>
View
2  picocontainer/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-picocontainer</artifactId>
View
2  pom.xml
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
<packaging>pom</packaging>
<name>Cucumber-JVM</name>
<url>http://cukes.info/</url>
View
2  rhino/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-rhino</artifactId>
View
1  rhino/src/main/java/cucumber/runtime/javascript/JavaScriptSnippet.java
@@ -11,6 +11,7 @@
public String template() {
return "{0}(/{1}/, function({3}) '{'\n" +
" // {4}\n" +
+ " throw new Packages.cucumber.runtime.PendingException();\n" +
"'}');\n";
}
View
15 rhino/src/main/java/cucumber/runtime/rhino/RhinoStepDefinition.java
@@ -7,6 +7,7 @@
import gherkin.formatter.Argument;
import gherkin.formatter.model.Step;
import org.mozilla.javascript.Context;
+import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.NativeFunction;
import org.mozilla.javascript.NativeJavaObject;
import org.mozilla.javascript.Scriptable;
@@ -48,7 +49,19 @@ public String getLocation() {
}
public void execute(I18n i18n, Object[] args) throws Throwable {
- bodyFunc.call(cx, scope, scope, args);
+ try {
+ bodyFunc.call(cx, scope, scope, args);
+ } catch (JavaScriptException e) {
+ Object value = e.getValue();
+ if (value instanceof NativeJavaObject) {
+ NativeJavaObject njo = (NativeJavaObject) value;
+ Object unwrapped = njo.unwrap();
+ if (unwrapped instanceof Throwable) {
+ throw (Throwable) unwrapped;
+ }
+ }
+ throw e.getCause() == null ? e : e.getCause();
+ }
}
public boolean isDefinedAt(StackTraceElement stackTraceElement) {
View
3  rhino/src/main/resources/cucumber/runtime/rhino/dsl.js
@@ -4,7 +4,6 @@ var registerStepDefinition = function(regexp, bodyFunc) {
if (match) {
var arguments = new Packages.java.util.ArrayList();
var s = match[0];
- var offset = 0;
for (i = 1; i < match.length; i++) {
var arg = match[i];
var offset = s.indexOf(arg, offset);
@@ -25,4 +24,4 @@ var Then = registerStepDefinition;
var World = function(func) {
// TODO: do this properly
func();
-}
+};
View
1  rhino/src/test/java/cucumber/runtime/javascript/JavaScriptSnippetTest.java
@@ -16,6 +16,7 @@ public void generatesPlainSnippet() {
String expected = "" +
"Given(/^I have (\\d+) cukes in my \"([^\"]*)\" belly$/, function(arg1, arg2) {\n" +
" // Express the Regexp above with the code you wish you had\n" +
+ " throw new Packages.cucumber.runtime.PendingException();\n" +
"});\n";
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
}
View
2  scala/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-scala</artifactId>
View
1  scala/src/main/scala/cucumber/runtime/ScalaSnippet.scala
@@ -10,6 +10,7 @@ class ScalaSnippetGenerator extends Snippet {
def template() =
"{0}(\"\"\"{1}\"\"\")'{' ({3}) =>\n" +
" //// {4}\n" +
+ " throw new PendingException()\n"
"'}'"
def tableHint() = null
View
2  spring/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-spring</artifactId>
View
2  weld/pom.xml
@@ -5,7 +5,7 @@
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<relativePath>../pom.xml</relativePath>
- <version>1.0.0.RC23</version>
+ <version>1.0.0.RC24</version>
</parent>
<artifactId>cucumber-weld</artifactId>

No commit comments for this range

Something went wrong with that request. Please try again.