Cucumber Report plugin
Test execution checks the stability of the product, irrespective of Manual or Automation tests. Thus, reporting is a very important factor as it will project the outcome of the execution. Cucumber has a nice feature to generate reports by integrating with open-source tools such as Junit.
Whenever any Cucumber Scenario is executed, an output gets automatically generated in the eclipse console. There is a default behavior associated with that output. But cucumber provides the feasibility to customize the default behavior. Let us look into it one by one.
Pretty Report
This plugin prints the Gherkin source with additional colors and stack traces for errors. This can be implemented by specifying plugin = “pretty” in CucumberOptions.
@CucumberOptions( plugin = { “pretty” } )
Test Runner Class will look like below:
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
,plugin= {"pretty"}
)
public class TestRunner {
}
Eclipse console Output
It is difficult to read the above report due to its format. Thus there is an option to filter this output in an easily understandable format by the help of “Monochrome”
Monochrome
This option can either set as true or false (default value is false). It is set as true to format the console output in a readable format. Otherwise, the output will be not in a readable format.
@CucumberOptions( monochrome = true )
Test Runner Class will look like below
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
,plugin= {"pretty"}
, monochrome = true
)
public class TestRunner {
}
Eclipse console Output
Usage Report
It tells about the time taken by each Step Definition to run. It is also specified under @CucumberOptions in similar way.
@CucumberOptions( plugin = { “usage” })
Test Runner Class will look like below
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
,plugin= {"usage"}
, monochrome = true
)
public class TestRunner {
}
Eclipse console Output
Cucumber HTML Report
For generating HTML reports, add keyword html:target/cucumber-reports to the @CucumberOptions plugin option.
@CucumberOptions( plugin = { “pretty”, “html:target/cucumber-reports” })
This will generate the report under target folder.
Test Runner Class will look like below
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
, plugin = {"pretty", "html:target/cucumber-reports"}
, monochrome = true
)
public class TestRunner {
}
HTML Report Output
Cucumber JSON Report
For generating JSON reports, add keyword json:target/cucumber-reports/Cucumber.json to the @CucumberOptions plugin option.
@CucumberOptions( plugin = { “pretty”, ” json:target/cucumber-reports/Cucumber.json” })
Test Runner Class will look like below
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
, plugin = {"pretty", " json:target/cucumber-reports/Cucumber.json "}
, monochrome = true
)
public class TestRunner {
}
JSON Report Output
Cucumber XML Report
For generating JSON reports, add keyword junit:targe/cucumber-reports/Cucumber.xml to the @CucumberOptions plugin option.
@CucumberOptions( plugin = { “pretty”, ” junit:targe/cucumber-reports/Cucumber.xml ” })
Test Runner Class will look like below
@RunWith(Cucumber.class)
@CucumberOptions(
features= "E:\\AutomationCode\\DemoBDD\\src\\main\\java\\com\\qa\\features"
,glue= {"com.qa.stepDefination"}
,tags= {"@SmokeTest"}
, plugin = {"pretty", " junit:targe/cucumber-reports/Cucumber.xml"}
, monochrome = true
)
public class TestRunner {
}
XML Report Output