Using Optional Capture and Noncapture Groups
Until now, we have covered how to write Step Definitions for various keywords in Feature files. Now let's talk about how we can efficiently use Step Definitions for multiple Steps.
Think about a situation where we are testing a positive situation in one Step and a negative situation in some other Step—the only difference in both Steps is just the word "No", while the remaining sentence is same. Based on the knowledge that we have acquired so far, we will write two Step Definitions for these two Steps. But is there a better way of doing this? Let's see how we can do this better in this recipe.
How to do it…
- For this recipe, consider the following Scenarios and focus on the highlighted text:
Scenario: Optional Capture Groups/Alternation #positive Then I see following dollars in my account #negative Then I do not see following dollars in my account Scenario: Optional Non capture Groups Given...