在JBoss AS 7集成测试套件中,我们使用JaCoCo进行代码覆盖.我已经有了执行数据.现在,当生成报告时,我得到"无法添加具有相同名称的不同类:..."所以我必须排除一些罐子.
<exclude name="org/jboss/osgi/framework/main/jbosgi-resolver-metadata-1.0.10.jar"/>
Run Code Online (Sandbox Code Playgroud)
问题是只有一个类是重复的(org/jboss/osgi/metadata/internal/AbstractPackageAttribute).我只希望排除特定的类,而不是整个jar.
我试过了:
<exclude name="org/jboss/osgi/framework/main/**/AbstractPackageAttribute*"/>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.是否有一些特殊的语法,比如.../foo.jar!**/ClassName.class?
我有一个maven项目,我想jacoco用于代码覆盖.这是我的pom的相关部分
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>pre-my-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-my-test</id>
<phase>post-my-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
所以我能够很好地运行我的测试,并且还可以很好地构建项目.然后我跑了
mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent
Run Code Online (Sandbox Code Playgroud)
我不断收到错误
ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:
report (post-my-test) on project my-project:
An error has occurred in JaCoCo Test report generation.
Error while creating report:
Error while analyzing class /path/tp/my/project/target/classes/META-INF/
bundled-dependencies/some-third-party-1-jar-with-dependencies.jar@org/slf4j/event/
EventConstants.class. Can't add different class with same name:
org/slf4j/event/EventConstants -> [Help …Run Code Online (Sandbox Code Playgroud)