Question

I am looking to use two variations of the same step I'm my ATDD test using cucumber-jvm

Then order passes quantity limits

and

Then order passes limits

This will read better with different scenarios. I have tried various variations of the following:

@Then(value = "^order passes (?: | quantity )limits$")
public void verifyCreditPassed(){ 
    //Assert stuff
}

Can anyone help?

Thanks

Was it helpful?

Solution

You need to remove the ^ and $ meta-characters then you regex becomes:

order passes (?:quantity |)limits

because when you use ^ the line must start with the word order and because you used $ the line must end with limits, the above regex will match your sentence anywhere inside the input string.

or use the following regex:

^Then order passes (?:quantity )?limits$

OTHER TIPS

Figured this option out also:

@Then(value = "^order passes(?: | quantity )limits$")
public void verifyCreditPassed(){ 

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top