首页 > 解决方案 > Thorntail arquillian jacoco 测试用例覆盖率显示 0%

问题描述

我正在使用 thorntail 框架并使用 Arquillian 开发集成测试用例。当我尝试生成测试用例覆盖率报告时,它显示 0% 的覆盖率。我已经尝试了许多解决方案,包括 thorntail-example、arquillian jacoco 扩展,但无法解决这个问题。下面是我的 pom.xml

    <profile>
        <id>jacoco</id>
        <dependencies>
            <dependency>
                <groupId>org.jacoco</groupId>
                <artifactId>org.jacoco.core</artifactId>
                <version>${version.jacoco}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.extension</groupId>
                <artifactId>arquillian-jacoco</artifactId>
                <version>${version.arquillian_jacoco}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.15</version>
                    <executions>
                        <!-- Ensures that both integration-test and verify goals of the Failsafe 
                            Maven plugin are executed. -->
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <!-- Sets the VM argument line used when integration tests are run. -->
                                <argLine>${failsafeArgLine}</argLine>

                                <!-- Skips integration tests if the value of skip.integration.tests 
                                    property is true -->
                                <skipTests>false</skipTests>
                                <systemPropertyVariables>
                                <thorntail.arquillian.jvm.args>${failsafeArgLine}</thorntail.arquillian.jvm.args>
                                </systemPropertyVariables>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${version.jacoco}</version>
                    <executions>
                        <execution>
                            <id>pre-integration-test</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <!-- Sets the path to the file which contains the execution data. -->
                                <destFile>${jacoco.it.execution.data.file}</destFile>
                                <!-- Sets the name of the property containing the settings for JaCoCo 
                                    runtime agent. -->
                                <propertyName>failsafeArgLine</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-integration-test</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <!-- Sets the path to the file which contains the execution data. -->
                                <dataFile>${jacoco.it.execution.data.file}</dataFile>
                                <!-- Sets the output directory for the code coverage report. -->
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

这是我的 arquillian.xml

<container default="true" qualifier="daemon">
    <configuration>
        <property name="host">localhost</property>
        <property name="port">${thorntail.arquillian.daemon.port:8085}</property>
        <property name="javaVmArguments">${thorntail.arquillian.jvm.args:}</property>
    </configuration>
</container>
<extension qualifier="jacoco">
    <property name="includes">com.*</property>
</extension>

标签: jboss-arquillianjacoco-maven-pluginthorntail

解决方案


推荐阅读