Cucumber: How to skip a single step and continue with the scenario (Java, JUnit)
I have a scenario with following structure:
Scenario Outline: Sections displayed on login
Given Robert is at the home page
When Robert logs in as "<role>"
Then the "<section1>" should be displayed
And the "<section2>" should be displayed
Examples:
| email | section1 | section2 |
| Administrator | Administration | Profile |
| External | IGNORED | Profile |
As you can see, there is a parameter "IGNORED" in the second example. In case I detect this keyword during runtime, I want the step, the keyword appeared in, to be skipped.
At the moment I use this:
@Then("the {string} should be displayed")
public void the_section_should_be_displayed(String sectionName) {
if(sectionName.contentEquals("IGNORED"))
return;
// rest of code
}
Here the step will be set as PASSED if the IGNORED keyword is there. What I want instead, is that this single step is marked as SKIPPED and that the following steps are still executed and the full test scenario is afterwards marked as PASSED or FAILED depending on the status of the other steps.
So my question is:
Is there a way to manually set a Cucumber step to status SKIPPED without skipping the rest of the scenario?
I am aware that I could simply create two scenarios, one for each role. But I currently have no choice. I can not change anything within the feature file and need to solve this with code. So please try to answer the question if you can. I appreciate any help!
Comments
Post a Comment