当我们JUnit
使用jmockit-coverage
进行测试时,我们只会通过添加对maven pom.xml
的依赖关系来配置它,如下所示。
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit-coverage</artifactId>
<scope>test</scope>
</dependency>
然后它将给出覆盖结果。所以我的问题是如何激活jmockit
覆盖范围?似乎我们从未运行过它的代码,但它运行了。
答案 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 -->
...