{"action":"created","issue":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/1183","repository_url":"https://api.github.com/repos/cucumber/cucumber-jvm","labels_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/1183/labels{/name}","comments_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/1183/comments","events_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/1183/events","html_url":"https://github.com/cucumber/cucumber-jvm/issues/1183","id":244374942,"number":1183,"title":"Better error when both DataTable and DocString supplied (was: Arity mismatch discrepancy)","user":{"login":"aslakhellesoy","id":1000,"avatar_url":"https://avatars3.githubusercontent.com/u/1000?v=4","gravatar_id":"","url":"https://api.github.com/users/aslakhellesoy","html_url":"https://github.com/aslakhellesoy","followers_url":"https://api.github.com/users/aslakhellesoy/followers","following_url":"https://api.github.com/users/aslakhellesoy/following{/other_user}","gists_url":"https://api.github.com/users/aslakhellesoy/gists{/gist_id}","starred_url":"https://api.github.com/users/aslakhellesoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslakhellesoy/subscriptions","organizations_url":"https://api.github.com/users/aslakhellesoy/orgs","repos_url":"https://api.github.com/users/aslakhellesoy/repos","events_url":"https://api.github.com/users/aslakhellesoy/events{/privacy}","received_events_url":"https://api.github.com/users/aslakhellesoy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-20T14:06:23Z","updated_at":"2017-07-20T14:06:24Z","closed_at":null,"body":"_From @kevlarC on August 3, 2016 8:5_\n\nUsing version 1.2.4 JVM in junit with either java/scala\n\nConsider this piece of Gherkin.\n\n```\n When  I POST a request to /some/url with:\n      | header        | value            |\n      | SomeHeader    | value            |\n      | AnotherHeader | value2           |\n      | Content-Type  | application/json |\n    \"\"\"\n    {\n       \"member\": \"value\",\n       \"member\": \"value2\"\n    }\n    \"\"\"\n```\n\nAnd this step method in scala (the same thing happens in java)\n\n``` scala\n  When(s\"^I POST a request to ([^ ]*) with:\") { (url: String, body: String, headers: DataTable) =>\n      println( headers )\n      println( url )\n      println( body )\n  }\n```\n\nthe error is:\n\n```\n\ncucumber.runtime.CucumberException: Arity mismatch: Step Definition 'Quote.scala:13' with pattern [^I POST a request to ([^ ]*) with:] is declared with 3 parameters. However, the gherkin step has 3 arguments [/v4/quote/create, DocString:{\n   \"till\": \"GB:a_store_id:a_till_id\",\n   \"currency\": \"GBP\"\n}, Table:[[header, value], [TraceId, a_trace_id], [ClientId, a_client_id:a_secret], [Authorization, Bearer:temporary_token], [Content-Type, application/json]]]. \nStep: When I POST a request to /v4/quote/create with:\n    at cucumber.runtime.StepDefinitionMatch.arityMismatch(StepDefinitionMatch.java:102)\n    at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:60)\n    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)\n    at cucumber.runtime.Runtime.runStep(Runtime.java:299)\n    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)\n    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)\n    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)\n    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)\n    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)\n    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)\n```\n\nTwo issues arise \n1) is this valid gherkin ?\n2) the error message obviously is incorrect saying all three parameters are there and it requires 3 parameters ?\n\nLooking at the code it seems to be either of these two lines:\n1) in release 1.2.4 lines 53-57 StepDefinitionMatch.java  arityMismatch()\n\n```\n       if (step.getRows() != null) {\n            argumentCount++;\n        } else if (step.getDocString() != null) {\n            argumentCount++;\n        }\n```\n\nif the gherkin is correct then this should be a if and then another if not if/else. The parameters might need fixing later on to get the correct items in place.\n\n2) or 114-116 Ste[DefinitionMatch.java arityMismatch. This should be the same as in 1) i.e. either if/else or if if. Ideally this should use exactly the same code to avoid this bug in the future.\n\n\n_Copied from original issue: cucumber/cucumber#56_"},"comment":{"url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/comments/316714165","html_url":"https://github.com/cucumber/cucumber-jvm/issues/1183#issuecomment-316714165","issue_url":"https://api.github.com/repos/cucumber/cucumber-jvm/issues/1183","id":316714165,"user":{"login":"aslakhellesoy","id":1000,"avatar_url":"https://avatars3.githubusercontent.com/u/1000?v=4","gravatar_id":"","url":"https://api.github.com/users/aslakhellesoy","html_url":"https://github.com/aslakhellesoy","followers_url":"https://api.github.com/users/aslakhellesoy/followers","following_url":"https://api.github.com/users/aslakhellesoy/following{/other_user}","gists_url":"https://api.github.com/users/aslakhellesoy/gists{/gist_id}","starred_url":"https://api.github.com/users/aslakhellesoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslakhellesoy/subscriptions","organizations_url":"https://api.github.com/users/aslakhellesoy/orgs","repos_url":"https://api.github.com/users/aslakhellesoy/repos","events_url":"https://api.github.com/users/aslakhellesoy/events{/privacy}","received_events_url":"https://api.github.com/users/aslakhellesoy/received_events","type":"User","site_admin":false},"created_at":"2017-07-20T14:06:24Z","updated_at":"2017-07-20T14:06:24Z","body":"You can't have both a data table and a doc string - only one of them. The fix would be to throw an error explaining that more clearly.\n"}}
{"actor":{"display_login":"aslakhellesoy"}}