Hello everyone,
I have this step on feature file
When I log in with invalid credentials
and in the stepsDefinition class
@When("^I log in with (wrong|invalid) credentials$")
public void login(){
}
I want to use on my feature step with wrong or invalid word using regex but I get this error
with pattern [^I log in with (.*) credentials$] is declared with 0 parameters. However, the gherkin step has 1 arguments [invalid]. Step: When I log in with invalid credentials at cucumber.runtime.StepDefinitionMatch.arityMismatch(StepDefinitionMatch.java:102) at cucumber.runtime.StepDefinitionMatch.transformedArgs(StepDefinitionMatch.java:60) at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37) at cucumber.runtime.Runtime.runStep(Runtime.java:299) 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:44) at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
PS: I'm using cucumber-java and cucumber-junit 1.2.4 version
Thanks in advance
You need to specify that this is a non-capturing group. Try this (?:wrong|invalid)
. The '?:' part makes sure that cucumber does not pass it as an argument to the method.