My app has permissions, and certain tests need to not be run when a particular permission is on, and some tests need to be run when that same permission is on.
Is there a way to do this? or do I need to use a different framework?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The standard way of excluding ‘tests’ in Cucumber is to add a tag to them to identify them, then when invoking Cucumber you specify which tags to include/exclude. In your example, you could tag a specific scenario:
Or tag the whole feature:
Or tag certain examples in a scenario outline:
Now, when you run Cucumber, you can exclude those tags if necessary:
When the permission is on and you want to run all tests:
When the permission is off and you want to exclude the tests that need it:
An alternative which I have used with mixed results, if you really don’t know ahead of time, is to mark a step as
pendingif it doesn’t apply given the current scenario, e.g.This will mark the step as ‘pending’ which really means ‘not fully implemented’, which isn’t ideal, especially if you have many such steps – it can be difficult to ensure that other unimplemented steps don’t accidentally creep in and get hidden by all the ones you’ve deliberately marked as such.