How to use Cluecumber to generate reports?

一笑奈何 提交于 2020-04-14 08:09:28

问题


How to generate reports for automation tests using Cluecumber.


回答1:


Posting and answering my own question in case it may be helpful to someone else.

  1. Add the Cluecumber plugin to your pom file. As of the time of this writing the most recent version is 2.3.4 but this can be checked here for updates.

    <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. Add json:target/cucumber-report/cucumber.json to your Runner, so you would have something like this:

    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: No need for html target

  1. Run your tests and once this is done navigate to the terminal and type mvn cluecumber-report:reporting (exactly as it is).

This will generate a folder that only appears when this command is run. It'll be under target folder and will be called generated-report. There you should find the index.html file where your reports should be (right click and open it on a browser to see it).



来源:https://stackoverflow.com/questions/60658416/how-to-use-cluecumber-to-generate-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!