我在 pom 的系统属性中使用 ${surefire.forkNumber} 。根据maven documentation ,它应该被解析为当前正在运行的 fork 的数量。但它解析为 null。
下面是我的 pom 文件的片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<systemPropertyVariables>
<database.name>My_Test_Schema_${surefire.forkNumber}</database.name>
</systemPropertyVariables>
</configuration>
</plugin>
我错过了什么吗?
拜托,任何人都可以抛出一些光......
最佳答案
${surefire.forkNumber}
可能被替换两次:首先被 maven-core 替换,然后被 surefire 替换。由于 maven-core 不知道这个属性,它在那里替换了 null
。
解决方案:通过引用 $
防止首次替换:
<systemPropertyVariables>
<database.name>My_Test_Schema_$${surefire.forkNumber}</database.name>
</systemPropertyVariables>
来源:http://maven.40175.n5.nabble.com/SureFire-2-16-doesn-t-respect-forkCount-td5771850.html#a5771855
这个对我有用 --- 我遇到了同样的问题。很遗憾,这没有记录在案。
关于maven - ${surefire.forkNumber} 总是解析为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22144287/