如何让maven cobertura和surefire插件一起工作?
我将 Surefire 和 cobertura 插件放入我的 pom.xml
中,但我无法将它们配置为正常工作。或者 cobertura 不运行或者测试执行两次。
那么,我如何配置这些插件,让它们一起运行并且只运行一次呢?
如果我以这种方式配置,cobertura 不会运行:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
如果我以这种方式配置,测试将执行两次:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
I put the surefire and cobertura plugins in my pom.xml
, but I can't configure them to work fine. Or cobertura doesn't run or the tests are executes twice.
So, how could I configure the plugins for they run together and just one time?
If I configure in this way, cobertura doesn't run:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
If I configure in this way, the tests are executes twice:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
测试将运行两次 - 就是这样。请参阅Samuel的评论使用maven运行junits和cobertura
The tests will run twice - it is just the way it is. See Samuel's comment running junits and cobertura with maven
这就是我如何让它在 cobertura 打开和 Surefire 关闭的情况下进行测试。
将其添加到您的 pom 中,或放入 -DuseSystemClassLoader=false 的 mvn 选项
This is how I got it to work for tests with cobertura on and surefire off.
Add this to your pom, or put in mvn options for -DuseSystemClassLoader=false