【问题标题】:How to use Cluecumber to generate reports?如何使用 Cluecumber 生成报告?
【发布时间】:2020-06-24 18:12:09
【问题描述】:

如何使用Cluecumber 生成自动化测试报告?

【问题讨论】:

  • 虽然这可能是很好的参考资料(我不了解技术),但我建议您更新您的问题以更具体。自我回答时,重要的是仍然要问问题,就好像您不是要回答的人一样。这有助于寻求者找到问题,并知道它与他们相关,从而更加强调正确答案
  • 谢谢@Sterling。如果由于技术正确,可以删除不赞成票,它现在已经更新。

标签: automation cucumber report


【解决方案1】:
  1. 将 Cluecumber 插件添加到您的 pom 文件中。截至撰写本文时,最新版本是 2.3.4,但可以通过 here 检查更新。

    <plugin>
        <groupId>com.trivago.rta</groupId>
            <artifactId>cluecumber-report-plugin</artifactId>
            <version>2.3.4</version>
            <executions>
                <execution>
                    <id>report</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>reporting</goal>
                    </goals>
                </execution>
            </executions>
          <configuration>
                <sourceJsonReportDirectory>${project.build.directory}/cucumber-report</sourceJsonReportDirectory>
                <generatedHtmlReportDirectory>${project.build.directory}/generated-report
                </generatedHtmlReportDirectory>
          </configuration>
      </plugin>
    
  2. json:target/cucumber-report/cucumber.json 添加到你的Runner,这样你就会有这样的东西:

    import io.cucumber.junit.CucumberOptions;
    import io.cucumber.junit.Cucumber;
    import org.junit.runner.RunWith;
    
    @RunWith(Cucumber.class)
    @CucumberOptions(
        features = {"."},
        glue = {"my_folder.steps", "my_folder.hooks"},
        monochrome = true,
        plugin = {"json:target/cucumber-report/cucumber.json"}
    )
    
    public class MainRunner {
    
    }
    

PS:不需要html目标

  1. 运行测试,完成后导航到终端并输入mvn cluecumber-report:reporting(原样)。

这将生成一个仅在运行此命令时出现的文件夹。它将位于target 文件夹下,名为generated-report。在那里,您应该可以找到您的报告所在的 index.html 文件(右键单击并在浏览器中打开以查看)。

【讨论】:

  • 有没有办法让这个报告使用不同于 index.html 的名称或在文件后添加一个日期?
  • 我认为无法更改文件名,因为每次您在终端上键入 maven 命令时都会自动生成该文件。 index.html 通常是 html 页面的默认值,老实说,我自己不会尝试更改它。但是我认为可以对内容进行一些自定义,只是我自己从未尝试过,因此您可能需要在互联网上查找一些可能存在的教程。
  • 嗨 Francislainy:是否可以在 POM 中添加命令 mvn crowdcumber-report:reporting 以生成报告,而无需在命令行中运行它?
  • 对不起,不知道没有 maven 命令的任何其他方式来运行它,但是如果你在 IntelliJ 上,你可以为 maven 模板创建运行配置并将命令粘贴到那里(没有 mvn 字),然后每次您需要报告时,您只需单击该配置上的运行,而不是输入整个内容。
猜你喜欢
  • 1970-01-01
  • 2019-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-29
  • 2014-09-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多