首页 文章

Jenkins中的故障安全html报告

提问于
浏览
6

我有一些与故障安全maven插件一起运行的集成测试(使用Selenium) . Failsafe仅生成XML报告文件 .

1)我想生成HTML报告

2)我想在Jenkins中有一个关于html报告的链接

对于1)我安装了“maven-surefire-report-plugin”来使用failafe-report-only目标 .

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-report-plugin</artifactId>
  <version>2.13</version>
  <executions>
    <execution>
      <phase>post-integration-test</phase>
      <goals>
        <goal>failsafe-report-only</goal>
      </goals>
    </execution>
  </executions>
</plugin>

但在标准输出中,似乎没有生成任何内容:

[INFO] 
[INFO] >>> maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats >>>
[INFO] 
[INFO] <<< maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats <<<
[INFO] 
[INFO] --- maven-surefire-report-plugin:2.13:failsafe-report-only (default) @ BaseContrats ---

在我的failsafe-reports目录中,我只有XML报告文件,但没有HTML报告文件 .

它是为故障安全生成html报告的好插件吗?

对于2),我安装了Jenkins插件“Selenium HTML报告”,并添加了帖子构建操作“Publish Selenium HTML report”,并为“Selenium tests results location”参数配置了“target / failsafe-reports”值,但没有在Jenkins界面中显示(当然因为我的html报告文件没有生成...) .

这两点可以帮助我吗?

1 回答

  • 5

    回答第1部分为Failsafe生成HTML报告 .

    将以下内容添加到pom.xml中

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <skipSurefireReport>${skipSurefireReport}</skipSurefireReport>
                    <reportsDirectories>
                        <reportsDirectory>${basedir}/target/failsafe-reports</reportsDirectory>
                    </reportsDirectories>
                </configuration>
            </plugin>
        </plugins>
    </reporting>
    <properties>
       <skipSurefireReport>true</skipSurefireReport>
    </properties>
    

    我假设你使用mvn验证使用failsafe-plugin运行集成测试 . 默认情况下,这会在 / target / failsafe-reports中生成( *.txt*.xml )报告 . 这应该在 <reportDirectories> 中指定 . 您可以指向任何具有TEST - * . xml报告的目录 .

    然后运行cmd

    mvn site
    

    这将为Failsafe运行集成测试生成html报告 . 默认情况下,文件位于 /target/site/failsafe-report.html . 这个位置可以改变 .

相关问题