Cucumber reports getting overwritten when a new feature file is executed

3.6k views Asked by At

I am writing a test suite and have came across an issue. I am using cucumber and have defined multiple feature files. When I run the test pack the progress (html report and json format) of one feature file gets over-written when the next feature file execution begins.

I have multiple test classes defined that runs these feature files. I am trying to find a way I can get a single html report for all feature runs to give a consolidated view.

Sample test files for ref:

@CucumberOptions(plugin = { "pretty", "html:target/report/html",
"json:target/report/json/result.json" })
public class BaseFeature {

}

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:test/feature/rest/query.feature"
, monochrome = true
, glue={"a.b.c.rest"})
public class RunTest1 extends BaseFeature {

}

@RunWith(Cucumber.class)
@CucumberOptions(features="classpath:test/feature/soap/book.feature"
, monochrome = true
, glue="a.b.c.soap")
public class RunTest2 extends BaseFeature {

}

Let know what can be done to have a consolidated report.

2

There are 2 answers

1
Himanshu Bhardwaj On BEST ANSWER

A bit late, but as committed I am posting the solution here. Cucumber has a maven plugin that can be used to generate reports.

<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>

plugin version is currently : 3.3.0

This plugin provides some useful configuration parameters, that allows you to bind multiple test reports in json format.

A sample implementation is as follows:

<plugins> ...

  <plugin>
    <groupId>net.masterthought</groupId>
    <artifactId>maven-cucumber-reporting</artifactId>
    <version>${maven-cucumber-reporting.version}</version>
    <executions>
      <execution>
        <id>execution</id>
        <phase>verify</phase>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <projectName>test-report</projectName>
          <outputDirectory>${project.build.directory}/bdd/report</outputDirectory>
          <cucumberOutput>${project.build.directory}/report/json</cucumberOutput>
          <parallelTesting>false</parallelTesting>
        </configuration>
      </execution>
    </executions>
  </plugin>

</plugins>

Configuration to be used:

cucumberOutput: Path to where all the json reports are kept after the cucumber run outputDirectory: Path to where the html report will be generated

That's it and have fun.

1
Avinash Anand On

Like i said in comment above, merge your suite into 1, then you'll get 1 report. Since each RunWith means one suite, so basically use only 1 suite to get 1 report.