我正在尝试基于变量 @tags 运行特定的 Gherkin 场景(如果可能的话)。例如,如果我的配置文件是“dev”,我想运行场景 1,如果配置文件是“qa”,我想运行场景 2。
我可以在我的 java 类中获取配置文件值。我还可以在命令行中传递标签并按上述方式运行它here https://stackoverflow.com/questions/20237753/maven-running-cucumber-specific-feature-files-or-folders。但这不是我正在寻找的东西。例如:
@QA
Scenario:I do x and check y
Given I do abc
Then the response is 200
@DEV
Scenario:I do y and check x
Given I do cde
Then the response is 500
我在 java 类中得到的配置文件值如下
System.getProperty("myprofile");
如何根据我的个人资料设置黄瓜标签,以便我可以在特定环境中运行特定测试?基本上,我不想在命令行中传递标签,而是想根据我的个人资料设置它。可能吗?如果没有,最好的方法是什么?
我使用 Maven 配置文件实现了这一点。在每个配置文件中,将黄瓜选项设置为
<profiles>
<profile>
<id>development</id>
<properties>
<cucumber.options>
--tags @myTags
</cucumber.options>
<properties>
</profile>
............
</profiles>
然后将其作为构建插件中的系统属性变量传递为
<build>
<plugins>
<plugin>
<configuration>
<systemPropertyVariables>
<cucumber.options>${cucumber.options}</cucumber.options>
</systemPropertyVariables>
</configuration>
<plugin>
</plugins>
</build>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)