I think I am copying the answer from here, but I still cannot get optional parameters to work. The two steps run independently, I just wanted to try and combine them.
Scenario:
Then(~/^set timeout(?: at (\d+) (min|hr))?$/) { int duration , String units ->
Works for
And set timeout at 30 min
But not for:
And set timeout
Which throws this error
groovy.lang.MissingMethodException: No signature of method: CucumberTestSteps$_run_closure56.doCall() is applicable for argument types: (null, null) values: [null, null] Possible solutions: doCall(int, java.lang.String), findAll(), findAll()
I've tried several other random locations for '?:' and '?' with no luck. Also several web searches which all come back to that syntax should work.
Cucumber recognizes it as a valid test because when I add
Then(~/^set timeout$/)
It recognises it as a duplicate step
cucumber.runtime.AmbiguousStepDefinitionsException: ✽.Then set timeout(test.feature:57) matches more than one step definition: ^set timeout$ in CucumberTestSteps.groovy:1128 ^set timeout(?: at (\d+) (min|hr))?$ in CucumberTestSteps.groovy:1148