如何激活jmockit-coverage?

时间:2016-10-08 12:31:07

标签: java jmockit

当我们JUnit使用jmockit-coverage进行测试时,我们只会通过添加对maven pom.xml的依赖关系来配置它,如下所示。

<dependency>
    <groupId>org.jmockit</groupId>
    <artifactId>jmockit-coverage</artifactId>
    <scope>test</scope>
</dependency>

然后它将给出覆盖结果。所以我的问题是如何激活jmockit覆盖范围?似乎我们从未运行过它的代码,但它运行了。

1 个答案:

答案 0 :(得分:0)

我想这是因为

中的-coverage
    <artifactId>jmockit-coverage</artifactId>

你试过吗

    <artifactId>jmockit</artifactId>
JMockit Tutorial建议的那样?

但也许您必须检查 surefire-plugin 的配置,请参阅JMocikt Tutorial

<plugin>
   <artifactId>maven-surefire-plugin</artifactId>
   <configuration>
      <systemPropertyVariables>
         <!-- At least one of the following needs to be set: -->
         <coverage-output>html</coverage-output>     <!-- or: html-nocp, serial, serial-append -->
         <coverage-metrics>all</coverage-metrics>    <!-- or: line, path, data -->
         <coverage-classes>loaded</coverage-classes> <!-- or a "*" expression for class names -->
...