Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue 318: added 'throws Throwable' to Java snippets #319

Merged
merged 1 commit into from
May 16, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/src/main/java/cucumber/runtime/java/JavaSnippet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String arguments(List<Class<?>> argumentTypes) {
@Override
public String template() {
return "@{0}(\"{1}\")\n" +
"public void {2}({3}) '{'\n" +
"public void {2}({3}) throws Throwable '{'\n" +
" // {4}\n" +
"{5} throw new PendingException();\n" +
"'}'\n";
Expand Down
20 changes: 10 additions & 10 deletions java/src/test/java/cucumber/runtime/java/JavaSnippetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class JavaSnippetTest {
public void generatesPlainSnippet() {
String expected = "" +
"@Given(\"^I have (\\\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\")\n" +
"public void I_have_cukes_in_my_belly(int arg1, String arg2) {\n" +
"public void I_have_cukes_in_my_belly(int arg1, String arg2) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -33,7 +33,7 @@ public void generatesPlainSnippet() {
public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Exception {
String expected = "" +
"@Given(\"^before (\\\\d+) after$\")\n" +
"public void before_after(int arg1) {\n" +
"public void before_after(int arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -45,7 +45,7 @@ public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Excep
public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars() {
String expected = "" +
"@Given(\"^I have (\\\\d+) cukes in: my \\\"([^\\\"]*)\\\" red-belly!$\")\n" +
"public void I_have_cukes_in_my_red_belly(int arg1, String arg2) {\n" +
"public void I_have_cukes_in_my_red_belly(int arg1, String arg2) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -57,7 +57,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars(
public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParameter() {
String expected = "" +
"@Given(\"^the DI system receives a message saying \\\"([^\\\"]*)\\\"$\")\n" +
"public void the_DI_system_receives_a_message_saying(String arg1) {\n" +
"public void the_DI_system_receives_a_message_saying(String arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -68,7 +68,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParamet
public void generatesSnippetWithEscapedDollarSigns() {
String expected = "" +
"@Given(\"^I have \\\\$(\\\\d+)$\")\n" +
"public void I_have_$(int arg1) {\n" +
"public void I_have_$(int arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -79,7 +79,7 @@ public void generatesSnippetWithEscapedDollarSigns() {
public void generatesSnippetWithEscapedParentheses() {
String expected = "" +
"@Given(\"^I have (\\\\d+) cukes \\\\(maybe more\\\\)$\")\n" +
"public void I_have_cukes_maybe_more(int arg1) {\n" +
"public void I_have_cukes_maybe_more(int arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -90,7 +90,7 @@ public void generatesSnippetWithEscapedParentheses() {
public void generatesSnippetWithEscapedBrackets() {
String expected = "" +
"@Given(\"^I have (\\\\d+) cukes \\\\[maybe more\\\\]$\")\n" +
"public void I_have_cukes_maybe_more(int arg1) {\n" +
"public void I_have_cukes_maybe_more(int arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -101,7 +101,7 @@ public void generatesSnippetWithEscapedBrackets() {
public void generatesSnippetWithDocString() {
String expected = "" +
"@Given(\"^I have:$\")\n" +
"public void I_have(String arg1) {\n" +
"public void I_have(String arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -113,7 +113,7 @@ public void generatesSnippetWithDocString() {
public void recognisesWordWithNumbers() {
String expected = "" +
"@Given(\"^Then it responds ([^\\\"]*)$\")\n" +
"public void Then_it_responds_UTF(int arg1) {\n" +
"public void Then_it_responds_UTF(int arg1) throws Throwable {\n" +
" // Express the Regexp above with the code you wish you had\n" +
"}\n";
assertEquals(expected, snippetFor("Then it responds UTF-8"));
Expand All @@ -123,7 +123,7 @@ public void recognisesWordWithNumbers() {
public void generatesSnippetWithDataTable() {
String expected = "" +
"@Given(\"^I have:$\")\n" +
"public void I_have(DataTable arg1) {\n" +
"public void I_have(DataTable arg1) throws Throwable {\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" +
Expand Down