jacoco报告中的硒测试覆盖范围0%

时间:2016-02-25 11:54:03

标签: selenium code-coverage maven-failsafe-plugin jacoco-maven-plugin

我正试图让测试运行maven failsafe以显示在jacoco报告中,我已拆分单元和集成测试,所有测试都通过,验证运行正常。

我在目标目录中获得了一个创建的集成测试报告,它总是显示零覆盖率,即使我使用selenium的基本测试确实遇到了一些控制器功能。

如何让jacoco获得硒驱动测试的覆盖范围?

单元测试报告很好,并向我展示了代码覆盖率,因此这仅适用于硒测试,我没有得到任何构建问题,测试确实运行,他们似乎没有得到任何报道报告。

下面是我的故障保护和jacoco pom文件片段,我正在运行maven clean验证,我也使用货物插件在tomcat中运行我的war文件,我正在使用幻影js maven插件。

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.12</version>
            <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>${skip.integration.tests}</skipTests>
                <systemPropertyVariables>
                    <phantomjs.binary>${phantomjs.binary}</phantomjs.binary>
                </systemPropertyVariables>
            </configuration>
            <executions>
                <execution>
                    <id>default</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

      <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.5.201505241946</version>
            <executions>
                <!-- Prepares the property pointing to the JaCoCo runtime agent which 
                    is passed as VM argument when Maven the Surefire plugin is executed. -->
                <execution>
                    <id>pre-unit-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <!-- Sets the path to the file which contains the execution data. -->
                        <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                        <!-- Sets the name of the property containing the settings for JaCoCo 
                            runtime agent. -->
                        <propertyName>surefireArgLine</propertyName>
                        <includes>
                            <include>com/test/**</include>
                        </includes>
                    </configuration>
                </execution>
                <!-- Ensures that the code coverage report for unit tests is created 
                    after unit tests have been run. -->
                <execution>
                    <id>post-unit-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <!-- Sets the path to the file which contains the execution data. -->
                        <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                        <!-- Sets the output directory for the code coverage report. -->
                        <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                    </configuration>
                </execution>
                <!-- Prepares the property pointing to the JaCoCo runtime agent which 
                    is passed as VM argument when Maven the Failsafe plugin is executed. -->
                <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>${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>
                <!-- Ensures that the code coverage report for integration tests after 
                    integration tests have been run. -->
                <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>${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>
            </executions>
        </plugin>

0 个答案:

没有答案