Skip to content

Commit 3f39086

Browse files
committed
Deprecated in favour of .
1 parent 31aeb16 commit 3f39086

File tree

18 files changed

+55
-29
lines changed

18 files changed

+55
-29
lines changed

History.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## [Git master](https://github.com/cucumber/cucumber-jvm/compare/v1.1.1...master)
22

3+
* [Core] Deprecated `cucumber.runtime.PendingException` in favour of `cucumber.api.PendingException`. (Aslak Hellesøy)
4+
* [Core] New `@cucumber.api.Pending` annotation for custom `Exception` classes that will cause a scenario to be `pending` instead of `failed`. ([#427](https://github.com/cucumber/cucumber-jvm/pull/427) agattiker)
35
* [Core] `--name 'name with spaces in single quotes'` is working ([#379](https://github.com/cucumber/cucumber-jvm/issues/379), [#429](https://github.com/cucumber/cucumber-jvm/pull/429) William Powell)
46

57
## [1.1.1](https://github.com/cucumber/cucumber-jvm/compare/v1.0.14...1.1.1)

clojure/src/main/clj/cucumber/runtime/clj.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(str
2626
"({0} #\"{1}\" [{3}]\n"
2727
" (comment {4} )\n"
28-
" (throw (cucumber.runtime.PendingException.)))\n"))
28+
" (throw (cucumber.api.PendingException.)))\n"))
2929
(arguments [_ argumentTypes]
3030
(str/replace (SnippetGenerator/untypedArguments argumentTypes)
3131
"," ""))

clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class ClojureSnippet implements Snippet {
1515
public String template() {
1616
return "({0} #\"{1}\" [{3}]\n" +
1717
" (comment {4} )\n" +
18-
" (throw (cucumber.runtime.PendingException.)))\n";
18+
" (throw (cucumber.api.PendingException.)))\n";
1919
}
2020

2121
@Override

clojure/src/test/java/cucumber/runtime/clojure/ClojureSnippetTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void generatesPlainSnippet() {
2222
String expected = "" +
2323
"(Given #\"^I have (\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\" [arg1 arg2]\n" +
2424
" (comment Express the Regexp above with the code you wish you had )\n" +
25-
" (throw (cucumber.runtime.PendingException.)))\n";
25+
" (throw (cucumber.api.PendingException.)))\n";
2626
assertEquals(expected, snippet);
2727
}
2828

@@ -34,7 +34,7 @@ public void generatesSnippetWithDataTable() {
3434
String expected = "" +
3535
"(Given #\"^I have:$\" [arg1]\n" +
3636
" (comment Express the Regexp above with the code you wish you had )\n" +
37-
" (throw (cucumber.runtime.PendingException.)))\n";
37+
" (throw (cucumber.api.PendingException.)))\n";
3838
assertEquals(expected, snippet);
3939
}
4040
}

clojure/src/test/resources/cucumber/runtime/clojure/stepdefs.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
(Given #"^(\d+) unimplemented step$" [arg1]
2828
(comment Express the Regexp above with the code you wish you had )
29-
(throw (cucumber.runtime.PendingException. "This is pending. Seeing a stacktrace here is normal.")))
29+
(throw (cucumber.api.PendingException. "This is pending. Seeing a stacktrace here is normal.")))
3030

3131
(def most-recent (atom nil))
3232

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cucumber.api;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* Any exception class annotated with this annotation will be treated as a "pending" exception.
10+
* That is - if the exception is thrown from a step definition or hook, the scenario's status will
11+
* be pending instead of failed.
12+
*
13+
* @see PendingException
14+
*/
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Target(ElementType.TYPE)
17+
public @interface Pending {
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cucumber.api;
2+
3+
// We're deliberately not extending CucumberException (which is used to signal fatal errors)
4+
@Pending
5+
public class PendingException extends RuntimeException {
6+
public PendingException() {
7+
this("TODO: implement me");
8+
}
9+
10+
public PendingException(String message) {
11+
super(message);
12+
}
13+
}

core/src/main/java/cucumber/runtime/Pending.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

core/src/main/java/cucumber/runtime/PendingException.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package cucumber.runtime;
22

3-
// We're deliberately not extending CucumberException (which is used to signal fatal errors)
3+
import cucumber.api.Pending;
4+
5+
/**
6+
* @see cucumber.api.PendingException
7+
* @deprecated Use cucumber.api.PendingException
8+
*/
9+
@Deprecated
410
@Pending
511
public class PendingException extends RuntimeException {
612
public PendingException() {

core/src/main/java/cucumber/runtime/Runtime.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cucumber.runtime;
22

3+
import cucumber.api.Pending;
34
import cucumber.runtime.io.ClasspathResourceLoader;
45
import cucumber.runtime.io.ResourceLoader;
56
import cucumber.runtime.model.CucumberFeature;
@@ -208,7 +209,6 @@ private void runHookIfTagsMatch(HookDefinition hook, Reporter reporter, Set<Tag>
208209
}
209210
}
210211

211-
212212
//TODO: Maybe this should go into the cucumber step execution model and it should return the result of that execution!
213213
@Override
214214
public void runUnreportedStep(String uri, I18n i18n, String stepKeyword, String stepName, int line, List<DataTableRow> dataTableRows, DocString docString) throws Throwable {
@@ -279,10 +279,7 @@ public void runStep(String uri, Step step, Reporter reporter, I18n i18n) {
279279
}
280280

281281
private static boolean isPending(Throwable t) {
282-
if (t.getClass().isAnnotationPresent(Pending.class)) {
283-
return true;
284-
}
285-
return Arrays.binarySearch(PENDING_EXCEPTIONS, t.getClass().getName()) >= 0;
282+
return t.getClass().isAnnotationPresent(Pending.class) || Arrays.binarySearch(PENDING_EXCEPTIONS, t.getClass().getName()) >= 0;
286283
}
287284

288285
public void writeStepdefsJson() throws IOException {

core/src/test/java/cucumber/runtime/RuntimeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cucumber.runtime;
22

3+
import cucumber.api.PendingException;
34
import cucumber.runtime.io.ClasspathResourceLoader;
45
import cucumber.runtime.io.ResourceLoader;
56
import cucumber.runtime.model.CucumberFeature;

java/src/test/resources/cucumber-tck/cucumber_java_mappings.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def write_pending_mapping(step_name)
123123
public class Mappings<%= @@mappings_counter %> {
124124
@Given("<%= step_name -%>")
125125
public void <%= step_name.gsub(/[\s:]/, '_') -%>() {
126-
throw new cucumber.runtime.PendingException();
126+
throw new cucumber.api.PendingException();
127127
}
128128
}
129129

jruby/src/main/java/cucumber/runtime/jruby/JRubyBackend.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import cucumber.runtime.Backend;
66
import cucumber.runtime.CucumberException;
77
import cucumber.runtime.Glue;
8-
import cucumber.runtime.PendingException;
8+
import cucumber.api.PendingException;
99
import cucumber.runtime.UnreportedStepExecutor;
1010
import cucumber.runtime.io.Resource;
1111
import cucumber.runtime.io.ResourceLoader;

junit/src/main/java/cucumber/runtime/junit/JUnitReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cucumber.runtime.junit;
22

3-
import cucumber.runtime.PendingException;
3+
import cucumber.api.PendingException;
44
import gherkin.formatter.Formatter;
55
import gherkin.formatter.Reporter;
66
import gherkin.formatter.model.Background;

junit/src/test/java/cucumber/runtime/junit/JUnitReporterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cucumber.runtime.junit;
22

3-
import cucumber.runtime.PendingException;
3+
import cucumber.api.PendingException;
44
import gherkin.formatter.Formatter;
55
import gherkin.formatter.Reporter;
66
import gherkin.formatter.model.Result;

picocontainer/src/test/java/cucumber/runtime/java/picocontainer/StepDefs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package cucumber.runtime.java.picocontainer;
22

3+
import cucumber.api.PendingException;
34
import cucumber.api.Scenario;
45
import cucumber.api.java.After;
56
import cucumber.api.java.Before;
67
import cucumber.api.java.en.Given;
78
import cucumber.api.java.en.Then;
8-
import cucumber.runtime.PendingException;
99

1010
import java.util.List;
1111

rhino/src/main/java/cucumber/runtime/rhino/JavaScriptSnippet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class JavaScriptSnippet implements Snippet {
1111
public String template() {
1212
return "{0}(/{1}/, function({3}) '{'\n" +
1313
" // {4}\n" +
14-
" throw new Packages.cucumber.runtime.PendingException();\n" +
14+
" throw new Packages.cucumber.api.PendingException();\n" +
1515
"'}');\n";
1616
}
1717

rhino/src/test/java/cucumber/runtime/rhino/JavaScriptSnippetTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void generatesPlainSnippet() {
1616
String expected = "" +
1717
"Given(/^I have (\\d+) cukes in my \"([^\"]*)\" belly$/, function(arg1, arg2) {\n" +
1818
" // Express the Regexp above with the code you wish you had\n" +
19-
" throw new Packages.cucumber.runtime.PendingException();\n" +
19+
" throw new Packages.cucumber.api.PendingException();\n" +
2020
"});\n";
2121
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
2222
}

0 commit comments

Comments
 (0)