我们的项目是一个多模块 maven 项目,使用 clover2:instrument 生成检测的 fat jar。我们使用命令行中的检测 jar 评估功能测试代码覆盖率,所有步骤如下:
- mvn 干净安装
- mvn -P 仪器 clover2:仪器
- 运行功能测试
- mvn -P 仪器 clover2:aggregate
- mvn -P 仪器 clover2:clover 站点
所有单元测试都通过 clover 4.0.2 通过,但是当使用 clover 版本 3.1.8 时,它们因 NPE 而失败。我们想使用旧版本,因为我们有它的商业许可,而不是新版本。请帮忙。
我无法共享日志,因为这可能会违反我的组织政策。分享摘录
Tests run: 6, Failures: 6, Errors: 0, Skipped: 0, Time elapsed: 0 sec <<< FAILURE!
com.***.*.*.*.*.drools.*.*************UnitTest.testKnowledgeAgentInitialization() Time elapsed: 0 sec <<< FAILURE!
java.lang.NullPointerException
at com.***.*.*.*.*.drools.*.*************UnitTest.testKnowledgeAgentInitialization(*************UnitTest.java:149)
Parent POM for clover:
<profiles>
<profile>
<id>instrumentation</id>
<activation>
<property>
<name>instrumentation</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.atlassian.clover</groupId>
<artifactId>clover</artifactId>
<version>${version.clover}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>${version.clover}</version>
<configuration>
<license>${clover.license}</license>
<includesTestSourceRoots>false</includesTestSourceRoots>
</configuration>
<executions>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
We are using Surefire to run Unit tests
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<includes>
<include>**/*UnitTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testNGArtifactName>none:none</testNGArtifactName>
<reportsDirectory>${project.build.directory}/surefire-reports/testng</reportsDirectory>
</configuration>
</execution>
<execution>
<id>test-testng</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<junitArtifactName>none:none</junitArtifactName>
<reportsDirectory>${project.build.directory}/surefire-reports/junit</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
从日志中添加额外的堆栈虽然它并没有真正提供太多信息
运行 com。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest 测试运行:4,失败:4,错误:0,跳过:0,经过时间:0.27 秒 <<< 失败!com。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testKnowledgeAgentInitialization() 已用时间:0.002 秒 <<< 失败!com 上的 java.lang.NullPointerException。。气源。.*.drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testKnowledgeAgentInitialization(ApplyQueryValueThrottleEngineUnitTest.java:145)
com。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testNoM hingRule() 已用时间:0.266 秒 <<< 失败!com 上的 java.lang.NullPointerException。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testNoM hinRule(ApplyQueryValueThrottleEngineUnitTest.java:124)
com。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testM hingRule() 已用时间:0 秒 <<< 失败!com 上的 java.lang.NullPointerException。。气源。. .drools.ruleengine.ApplyQueryValueThrottleEngineUnitTest.testM hinRule(ApplyQueryValueThrottleEngineUnitTest.java:135)