Search code examples
cucumberautomated-testscalabash

Cucumber "OR" clause?


Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?

I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.

Something like that:

"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"

My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.


Solution

  • OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html

    But perhaps you could make use of the But keyword to achieve what you are looking for.