使用以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<environment>${env}</environment>
</systemPropertyVariables>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
执行命令时 mvn verify -Denv = http://localhost:8080 集成测试执行两次,一次使用env value = null导致测试失败,其他测试失败,导致所需的env值。因此它使用不同的结果执行测试两次