我们有一个持续的需求,我不知道如何使用现有的 Maven 2 工具和文档来解决。
我们的一些开发人员有一些运行时间很长的 JUnit 测试(通常是压力测试),在任何情况下都不应将其作为构建过程/夜间构建的常规部分运行。
当然,我们可以使用 surefire 插件的排除机制,将它们从构建中剔除,但理想情况下,我们会喜欢允许开发人员通过 Maven 2 随意运行它们的东西。
最佳答案
通常你会在你的 maven 配置中添加一个配置文件来运行一组不同的测试:
使用 mvn -Pintegrationtest install 运行它
<profile>
<id>integrationtest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-client -Xmx896m -XX:MaxPermSize=192m</argLine>
<forkMode>once</forkMode>
<includes>
<include>**/**/*Test.java</include>
<include>**/**/*IntTest.java</include>
</includes>
<excludes>
<exclude>**/**/*SeleniumTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<activation>
<property>
<name>integrationtest</name>
</property>
</activation>
</profile>
关于java - 有没有办法将长时间运行的(例如压力测试)分开,这样它们就不会在 Maven 2 中默认运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/251730/