【问题标题】:Missing Jacoco Code Coverage and IncompatibleClassChangeError缺少 Jacoco 代码覆盖率和 IncompatibleClassChangeError
【发布时间】:2016-08-11 20:01:04
【问题描述】:

我有一个带有一些 Arquillian 测试的 maven 项目(包括无人机/石墨烯测试)。

当我使用 maven 构建项目时,我所有使用 Graphene 和 Drone 或 Warp 的 Arquillian 测试都将失败并出现以下异常

Running de.mmo.arq.model.diverses.stammdaten.geldinstitut.GeldinstitutBlzTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.862 sec <<< FAILURE! - in de.mmo.arq.model.diverses.stammdaten.geldinstitut.GeldinstitutBlzTest
de.mmo.arq.model.diverses.stammdaten.geldinstitut.GeldinstitutBlzTest  Time elapsed: 4.862 sec  <<< ERROR!
org.jboss.shrinkwrap.api.exporter.ArchiveExportException: Failed to write asset to output: /WEB-INF/classes/de/mmo/base/dao/CrudService.class
Caused by: java.lang.IncompatibleClassChangeError: class org.jacoco.core.internal.flow.ClassProbesVisitor has interface org.objectweb.asm.ClassVisitor as super class

这就是魔法应该发生的地方

<build>
    <finalName>browser</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagBase>...</tagBase>
                <useReleaseProfile>false</useReleaseProfile>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>jacoco</id>
        <dependencies>
            <dependency>
                <groupId>org.jacoco</groupId>
                <artifactId>org.jacoco.core</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>arq-wildfly</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire}</version>
                    <configuration>
                        <skipTests>false</skipTests>
                        <systemPropertyVariables>
                            <arquillian.launch>wildfly-remote</arquillian.launch>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire}</version>
                    <configuration>
                        <skipTests>true</skipTests>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>${wildfly.maven-plugin}</version>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

我正在使用 mvn 以这个目标构建我的项目 clean package -fae 使用这个配置文件 jacoco arq-wildfly

构建失败,在我的目标目录中创建了 jacoco.exec 文件。

如果我删除 jacoco 配置文件中的目标 prepare-agent 并使用配置文件 jacoco arq- 运行相同的 mvn 命令(clean package -fae) wildfly 我的所有测试都成功完成,但没有创建 jacoco.exec 文件。

我做错了什么?有人有使用 Arquillian 和 Drone/Graphene Tests 和 Jacoco 进行代码覆盖的工作示例吗?

有关我的环境的更多信息:

  • 野蝇 10
  • Arquillian Core 1.1.11.Final
  • Arquillian 无人机 1.3.1.Final
  • Arquillian 石墨烯 2.1.0.Beta1
  • Arquillian Jacoco 1.0.0.Alpha8
  • Jacoco 0.7.6.201602180812

【问题讨论】:

    标签: java maven jboss-arquillian jacoco-maven-plugin arquillian-drone


    【解决方案1】:

    您的类路径中有多个 asm 版本,jacoco 需要最新的版本。

    使用mvn dependency:tree 查找 asm 版本,我认为您的依赖项中有 asm:asmorg.ow2.asm:asm-debug-all

    排除旧版本(asm:asm)对于需要asm的依赖项如下:

    <dependency>
        <groupId>...</groupId>
        <artifactId>...</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>asm</artifactId>
                <groupId>asm</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    

    对于无人机来说,它会是这样的:

    <dependency>
        <groupId>org.jboss.arquillian.graphene</groupId>
        <artifactId>graphene-webdriver</artifactId>
        <type>pom</type>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>asm</artifactId>
                <groupId>asm</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 2012-06-11
      • 2016-11-11
      • 2019-01-02
      • 2012-11-02
      • 2014-11-09
      • 1970-01-01
      • 2018-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多