[英]How to pull a specific scenario from a cucumber feature file using regex
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.
我正在使用Java regex解析文件,并希望根据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. 我想拉出包含
dog
的场景并将其转储到单独的文件中。 In my real life dog=account number
and associates to multiple SQL extracts which are auto-loaded into a local database. 在我的现实生活中,
dog=account number
并且与多个SQL提取关联,这些提取自动加载到本地数据库中。 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. 因此,在方案顶部使用
@run
不是一个简单的情况。 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? 有谁知道我可以退出那个小组吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.