1

目标:使用failsafe和jacoco这两个插件来创建集成测试报告。问题:已创建预期的报告,但显示覆盖率为 0%。 报告html

这是 pom.xml 中关于 jacoco 的代码。

 <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.7.8-SNAPSHOT</version>
    <executions>
        <execution>
            <!--prepare-agent -->
        </execution>
        <execution>
            <!--report -->
        </execution>
        <execution>
            <id>pre-integration-test</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>prepare-agent-integration</goal>
            </goals>
            <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</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>integration-test</phase>
            <goals>
                <goal>report-integration</goal>
            </goals>
            <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                <!-- Sets the output directory for the code coverage report. -->
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
            </configuration>
        </execution>
        <execution>
            <!--check -->
        </execution>

    </executions>
</plugin>    

这是关于故障安全的代码。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.16</version>
    <executions>
        <execution>
            <id>execute-local-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
            <configuration>
                <systemPropertyVariables>
                    <integration.test.server.url>http://${local.server.host}:${local.server.http.port}</integration.test.server.url>
                </systemPropertyVariables>
            </configuration>
        </execution>
        <execution>
            <id>verify-local-integration-tests</id>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <!-- Sets the VM argument line used when integration tests are run. -->
        <argLine>${failsafeArgLine}</argLine>
        <skip>${skipIntegrationTests}</skip>
        <excludes>
            <exclude>**/unittest/**/*Test.java</exclude>
            <exclude>**/unittest/**/*UT.java</exclude>
        </excludes>
        <includes>
            <include>**/integrationtest/*IT.java</include>
        </includes>
    </configuration>
</plugin>

我已经为此工作了很长时间。等待您的帮助,谢谢。

4

0 回答 0