Skip to content

Remove 'throws Exception' from JavaSnippet method signature #1308

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

Merged
merged 1 commit into from
Jan 4, 2018
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 @@ -10,7 +10,7 @@ protected String getArgType(Class<?> argType) {
@Override
public String template() {
return "@{0}(\"{1}\")\n" +
"public void {2}({3}) throws Exception '{'\n" +
"public void {2}({3}) '{'\n" +
" // {4}\n" +
"{5} throw new PendingException();\n" +
"'}'\n";
Expand Down
26 changes: 13 additions & 13 deletions java/src/test/java/cucumber/runtime/java/JavaSnippetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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) throws Exception {\n" +
"public void i_have_cukes_in_my_belly(int arg1, String arg2) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -38,7 +38,7 @@ public void generatesPlainSnippet() {
public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Exception {
String expected = "" +
"@Given(\"^before (\\\\d+) after$\")\n" +
"public void before_after(int arg1) throws Exception {\n" +
"public void before_after(int arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -50,7 +50,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) throws Exception {\n" +
"public void i_have_cukes_in_my_red_belly(int arg1, String arg2) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -61,7 +61,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) throws Exception {\n" +
"public void the_DI_system_receives_a_message_saying(String arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -72,7 +72,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParamet
public void generatesSnippetWithEscapedDollarSigns() {
String expected = "" +
"@Given(\"^I have \\\\$(\\\\d+)$\")\n" +
"public void i_have_$(int arg1) throws Exception {\n" +
"public void i_have_$(int arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -83,7 +83,7 @@ public void generatesSnippetWithEscapedDollarSigns() {
public void generatesSnippetWithEscapedQuestionMarks() {
String expected = "" +
"@Given(\"^is there an error\\\\?:$\")\n" +
"public void is_there_an_error() throws Exception {\n" +
"public void is_there_an_error() {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -94,7 +94,7 @@ public void generatesSnippetWithEscapedQuestionMarks() {
public void generatesSnippetWithLotsOfEscapes() {
String expected = "" +
"@Given(\"^\\\\^\\\\(\\\\[a-z\\\\]\\\\*\\\\)\\\\?\\\\.\\\\+\\\\$$\")\n" +
"public void a_z_$() throws Exception {\n" +
"public void a_z_$() {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -105,7 +105,7 @@ public void generatesSnippetWithLotsOfEscapes() {
public void generatesSnippetWithEscapedParentheses() {
String expected = "" +
"@Given(\"^I have (\\\\d+) cukes \\\\(maybe more\\\\)$\")\n" +
"public void i_have_cukes_maybe_more(int arg1) throws Exception {\n" +
"public void i_have_cukes_maybe_more(int arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -116,7 +116,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) throws Exception {\n" +
"public void i_have_cukes_maybe_more(int arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -127,7 +127,7 @@ public void generatesSnippetWithEscapedBrackets() {
public void generatesSnippetWithDocString() {
String expected = "" +
"@Given(\"^I have:$\")\n" +
"public void i_have(String arg1) throws Exception {\n" +
"public void i_have(String arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand All @@ -139,7 +139,7 @@ public void generatesSnippetWithDocString() {
public void recognisesWordWithNumbers() {
String expected = "" +
"@Given(\"^Then it responds ([^\\\"]*)$\")\n" +
"public void Then_it_responds(String arg1) throws Exception {\n" +
"public void Then_it_responds(String arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
"}\n";
assertEquals(expected, snippetFor("Then it responds UTF-8"));
Expand All @@ -149,7 +149,7 @@ public void recognisesWordWithNumbers() {
public void generatesSnippetWithDataTable() {
String expected = "" +
"@Given(\"^I have:$\")\n" +
"public void i_have(DataTable arg1) throws Exception {\n" +
"public void i_have(DataTable arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" // For automatic transformation, change DataTable to one of\n" +
" // List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.\n" +
Expand All @@ -166,7 +166,7 @@ public void generatesSnippetWithDataTable() {
public void generateSnippetWithOutlineParam() {
String expected = "" +
"@Given(\"^Then it responds (.*)$\")\n" +
"public void then_it_responds(String arg1) throws Exception {\n" +
"public void then_it_responds(String arg1) {\n" +
" // Write code here that turns the phrase above into concrete actions\n" +
" throw new PendingException();\n" +
"}\n";
Expand Down