如何使用 Cucumber 配置文件动态使用不同的环境主机名、testdata、testGroup。我正在使用黄瓜,java,maven
How do I use cucumber profile to dynamically use different environment hostname, testdata, testGroup. I am using cucumber, java, maven
我在功能文件中编写了测试用例。测试用例根据要求进行标记。
我希望通过传递配置文件名称,使用 maven 命令在不同的环境中执行这些测试用例。
每个配置文件将具有特定环境的主机名、用户名和密码。
我该如何实现?
@stage_ready
Feature: GUI Tests
Background:
Given the site <hostname> is reached using "Chrome" browser
When maximize window
And credentials <user_host> is typed into the "sd_username_editbox"
And credentials <password_host> is typed into the "sd_password_editbox"
And the "sd_login_button" button is clicked
命令行:
mvn test -Dcucumber.options=”–tags @stage_ready” -p profile_name
我想知道如何编写配置文件,它将具有主机名等参数,user_host,password_host 用于不同的配置文件,并在黄瓜步骤中动态使用,我已在角度中标记括号供参考。
来自Cucumber documentation:
"Profiles are not available in Java."
如果你想给Maven传递参数,你可以使用Maven profiles
例如(来自上面的 Maven link):
<project>
...
<profiles>
<profile>
<id>appserverConfig-dev</id>
<activation>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<properties>
<appserver.home>/path/to/dev/appserver</appserver.home>
</properties>
</profile>
<profile>
<id>appserverConfig-dev-2</id>
<activation>
<property>
<name>env</name>
<value>dev-2</value>
</property>
</activation>
<properties>
<appserver.home>/path/to/another/dev/appserver2</appserver.home>
</properties>
</profile>
</profiles>
..
</project>
我在功能文件中编写了测试用例。测试用例根据要求进行标记。 我希望通过传递配置文件名称,使用 maven 命令在不同的环境中执行这些测试用例。 每个配置文件将具有特定环境的主机名、用户名和密码。 我该如何实现?
@stage_ready
Feature: GUI Tests
Background:
Given the site <hostname> is reached using "Chrome" browser
When maximize window
And credentials <user_host> is typed into the "sd_username_editbox"
And credentials <password_host> is typed into the "sd_password_editbox"
And the "sd_login_button" button is clicked
命令行:
mvn test -Dcucumber.options=”–tags @stage_ready” -p profile_name
我想知道如何编写配置文件,它将具有主机名等参数,user_host,password_host 用于不同的配置文件,并在黄瓜步骤中动态使用,我已在角度中标记括号供参考。
来自Cucumber documentation: "Profiles are not available in Java."
如果你想给Maven传递参数,你可以使用Maven profiles
例如(来自上面的 Maven link):
<project>
...
<profiles>
<profile>
<id>appserverConfig-dev</id>
<activation>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<properties>
<appserver.home>/path/to/dev/appserver</appserver.home>
</properties>
</profile>
<profile>
<id>appserverConfig-dev-2</id>
<activation>
<property>
<name>env</name>
<value>dev-2</value>
</property>
</activation>
<properties>
<appserver.home>/path/to/another/dev/appserver2</appserver.home>
</properties>
</profile>
</profiles>
..
</project>