View on GitHub

Cucumber Reports

Detailed Test Results Report

Download this project as a .zip file Download this project as a tar.gz file

Where is it used?

Detailed report is some kind of enhancement for standard Cucumber HTML report. It is major source for test results analysis.

Major sections

Detailed report consists of 3 major sections:

Overview

Overview Section

Overview section contains aggregated information on run status per features/scenarios/steps. It’s some kind of results summary.

Table of Contents

TOC Section

Table of contents is hyper-linked list of features and scenarios in the report. Each link refers to detailed results section for specific feature/scenario.

Detailed Results

Detailed Section

Detailed results section contains steps performed with their statuses. Also, this section contains screen shots.

Additional report generation options

Aggregated results

Results aggregation is the part of failed tests re-run functionality. If we use tests re-run we receive report containing all results for all re-tries. Usually it distorts actual picture. Aggregation is targeted to show the latest execution status for each test.

NOTE: when you define that test results should be aggregated the original report is still generated. So, generally you’ll see 2 reports generated:

  • Regular report - file with simple -test-results.html suffix. It still contains retries information.
  • Aggregated report - file with -agg-test-results.html suffix. It already shows results after all retries.

Also, if you define PDF report generation option only aggregated report is exported to PDF.

Screen shots

Currently major supported way to include screen shots is embedding them into JSON report. Below is the sample code which is to be used as a part of hooks and which generates screen shot if test was ended with error:

@After
public void tearDown(Scenario scenario) {
	if (scenario.getStatus().equalsIgnoreCase("failed")) {
	    try {
            File scrFile = getScreenShotFile();
			byte[] data = FileUtils.readFileToByteArray(scrFile);
			scenario.embed(data, "image/png");
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	}
}

Here the getScreenShotFile() method is some method getting screen shot and storing to file. Actual implementation depends on the technology and can be varying. But entire structure is the same.

Once you have the screen shot embedded the detailed report will inject it into it’s body.

Generating report from code

CucumberDetailedResults results = new CucumberDetailedResults();
results.setOutputDirectory("target/");
results.setOutputName("cucumber-results");
results.setSourceFile("./src/test/resources/cucumber.json");
results.setScreenShotLocation("../src/test/resources/");
results.execute(true, false);
results.execute(false, false);

Generating report via Cucumber runner

package com.github.mkolisnyk.cucumber.reporting;

import org.junit.runner.RunWith;

import com.github.mkolisnyk.cucumber.runner.ExtendedCucumber;
import com.github.mkolisnyk.cucumber.runner.ExtendedCucumberOptions;

import cucumber.api.CucumberOptions;

@RunWith(ExtendedCucumber.class)
@ExtendedCucumberOptions(
        jsonReport = "target/cucumber.json",
        detailedReport = true,
        detailedAggregatedReport = true,
        toPDF = true,
        outputFolder = "target/LoginReport/ExtendedReport")
@CucumberOptions(
        features = { "src/test/java/com/github/mkolisnyk/cucumber/features/63.feature" },
        glue = "com/github/mkolisnyk/cucumber/steps", plugin = {
        "html:target/LoginReport", "json:target/cucumber.json",
        "pretty:target/cucumber-pretty.txt",
        "usage:target/cucumber-usage.json", "junit:target/cucumber-results.xml" })
public class SampleTest {
}

News