I have a cucumber feature file that contains multiple scenarios and each has a different And. I am using Java regex to parse the file and want to pull out a specific scenario based on the text in the And.
For example:
Feature: testing stuff
Scenario:
lady swallows fly Given a lady and lady swallows a "fly" then lady lives
Scenario:
lady swallows spider Given a lady and lady swallows a "fly","spider" then lady lives
Scenario:
lady swallows everything Given a lady and lady swallows a "fly","spider","cat","dog","cow" then lady Dies
Scenario:
lady swallows everything except the dog Given a lady and lady swallows a "fly","spider","cat","cow" then lady Dies
I want to pull out the scenario that contains dog and dump it in a separate file. In my real life dog=account number and associates to multiple SQL extracts which are auto-loaded into a local database. This is a single scenario, in a single feature file, which is one of hundreds. So it's not a simple case of using @run at the top of the scenario. I am actually extracting the scenario and associated files so they can be put in a sandbox.
The regex that I have so far is:
.*?dog.*Scen
but that selects from the first instance of Scenario into the Scenario beyond what I want.
Instead I want to pull out the group:
Scenario:
lady swallows everything Given a lady and lady swallows a "fly","spider","cat","dog","cow" then lady Dies
Does anyone know how I can pull out that group?