基于 Maven 配置文件的黄瓜标签
cucumber tags based on maven profile
我正在尝试 运行 基于变量 @tags(如果可能)的特定 Gherkin 场景。例如,如果我的个人资料是 "dev",我想 运行 场景 1,如果个人资料是 "qa",我想 运行 场景 2。
我可以在我的 java class 中获取配置文件值。我还可以在命令行中传递标签,并且 运行 如前所述 here。但这不是我要找的东西。例如:
@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 class 中获取配置文件值作为
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>
我正在尝试 运行 基于变量 @tags(如果可能)的特定 Gherkin 场景。例如,如果我的个人资料是 "dev",我想 运行 场景 1,如果个人资料是 "qa",我想 运行 场景 2。 我可以在我的 java class 中获取配置文件值。我还可以在命令行中传递标签,并且 运行 如前所述 here。但这不是我要找的东西。例如:
@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 class 中获取配置文件值作为
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>