我使用基于 Maven 构建的 Selenium WebDriver 和 Cucumber-jvm 创建测试。接下来我想实现:
我想拥有带有属性的配置文件,并根据环境在我的步骤中使用此属性。
我在其中创建了一个文件夹src/test/resources并在其中添加了 2 个子文件夹:Staging和Dev.
在每个文件夹中,我都有一个config.properties保存username.
我的 POM 看起来像:
<profiles>
<profile>
<id>staging</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
</properties>
</profile>
</profiles>
现在我想将配置文件的属性更改为这样的:
<properties> test/resources/dev/config.properties</properties>
<properties> test/resources/staging/config.properties</properties>
我希望当我在我的步骤 defs 中使用活动暂存配置文件运行我的测试时:
system.getProperty("username")
我希望它返回usernamestaging 的属性中提供的。
当我在devprofile 处于活动状态时运行它时,我想获取dev的属性。
撒科打诨
拉莫斯之舞
相关分类