我想使用不同的Maven配置文件来设置不同的参数以满足测试需求。参数是URL。测试是在Groovy上进行的。我正在尝试:
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<useUrl>http://url</useUrl>
</properties>
</profile>
<profile>
<id>another</id>
<properties>
<useUrl>http://url2</useUrl>
</properties>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
和常规代码: baseUrl = System.getProperty("useUrl")
System.getProperty("useUrl") 始终返回“ null”。
但是,如果我在surefire插件中进行如下配置:
<systemPropertyVariables>
<baseUrl>${useUrl}</baseUrl>
</systemPropertyVariables>
Run Code Online (Sandbox Code Playgroud)
代码System.getProperty("useUrl")将完全返回我期望的值-活动配置文件(http://url或http://url2)中的值。
系统信息:Maven 3.2.5 Windows 8.1 Intellij IDEA 14.0.2
有人可以解释为什么配置文件属性不起作用吗?还是我做错了什么?提前致谢。