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

Arity mismatch. Declared parameters: [class java.lang.Object]. Matched arguments: [] #297

Closed
el-pablo opened this issue Apr 11, 2012 · 2 comments

Comments

@el-pablo
Copy link

I am getting the following stack trace, for a step like the following:

@357
Scenario: Carbon Coder executes unsuccessfully
  Given Carbon Coder is running correctly

And the step definition :

Given(~"Carbon Coder is running correctly\$") {
    transcodeHelper.prepareService()
}
cucumber.runtime.CucumberException: Arity mismatch. Declared parameters: [class java.lang.Object]. Matched arguments: []
    at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:69)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:43)
    at cucumber.runtime.Runtime.runStep(Runtime.java:223)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:36)
    at cucumber.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:76)
    at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:65)
    at cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:20)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at cucumber.junit.FeatureRunner.run(FeatureRunner.java:72)
    at cucumber.junit.Cucumber.runChild(Cucumber.java:75)
    at cucumber.junit.Cucumber.runChild(Cucumber.java:36)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at cucumber.junit.Cucumber.run(Cucumber.java:80)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:182)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

It works if I add a regex to the step definition. e.g.

Given(~"Carbon Coder (*.) running correctly\$") { String ignore ->
    transcodeHelper.prepareService()
}
@aslakhellesoy
Copy link
Contributor

You have to explicitly declare an empty list of closure parameters. So instead of this:

Given(~"Carbon Coder is running correctly\$") {
    transcodeHelper.prepareService()
}

Do this:

Given(~"Carbon Coder is running correctly\$") { ->
    transcodeHelper.prepareService()
}

Unfortunately it seems impossible to detect when a list of parameters is not supplied, so I can't give a better error message. You just have to know about this I guess.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
mpkorstanje pushed a commit that referenced this issue Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants