<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${masterThougth.version}</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<checkBuildResult>false</checkBuildResult>
<projectName>${project.artifactId}</projectName>
<buildNumber>${project.build}</buildNumber>
<parallelTesting>true</parallelTesting>
<outputDirectory>target/cucumber-report/</outputDirectory>
<cucumberOutput>target/cucumber-report/</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
I am using above maven cucumber plugin to generate HTML test report.How can I add new attribute to each steps in the html report,is it possible to add additional attributes other then the standard one's like START,END feature file name etc in the html report.I want to add screenshot for even passed test case.
This can be achieved by storing the scenario object in a global variable then using it in the step definition. For example,
Class Common{
public static Scenario scenario;
@before
public void beforeScenario(Scenario scenarioObj){
scenario = scenarioObj;
}
In step definitions, we can use it like,
Class step definitions{
@Given("^I am on homepage$")
public void iamonhomepage(){
Common.scenario. embed(take screenshot());
}
}
This embed method will attach the screenshot to the report. Also we can add some text messages to the report using write method of scenario object like
scenario.write("I am inside step definitions ");
Also we can use the formatting HTML tag in write method like
scenario.write("I am <b> inside </b> step definitions ");