Friday, 16 September 2022

Create an HTML report for BDD_Cucumber by adding a plugin?




Most Used Docker Commands:Interview Question

What is BDD?
Behaviour-driven development (BDD) is a collaborative software development approach that Cucumber was built to support. If you’d like to know more about the Cucumber Open source project take a look at the documentation. If you’d like to learn more about BDD, we have free online courses available at Cucumber School.

What is CUCUMBER?


Cucumber is a tool that can read feature files written in Gherkin (Given/When/Then) syntax and calls automation code for each line it finds. The fact that each scenario in the feature file either succeeds or fails means that you will always be able to determine whether your documentation accurately describes the behavior of your application. As a result, these feature files turn into live documentation for the application you're building.    

Cucumber provides us with the ability to produce reports in the formats of HTML, XML, JSON, and TXT. Cucumber frameworks produce excellent, thorough reports that may be distributed to all stakeholders. Depending on the need, there are a variety of reporting options that are available.

Create an HTML report by adding a plugin to testrunner.java class

Step 1:

In your testrunner.java class, add a plugin inside @CucumberOptions to format your test results into the HTML format.

plugin = { "pretty", "html:target/htmlreports" }

your full code will look like below:

Full Code

@CucumberOptions(
features = "src/test/resources/functionalTests",
glue= {"stepDefinitions"},
plugin = { "pretty", "html:target/htmlreports" },
monochrome = true
)

Note: We have specified the path of the Cucumber report, which we want it to generate under the target folder.

In order to set the path for the reports, we have to give a path in the project. To make this easier, the path is target/htmlreports.

Step 2:

Now save the testrunner.java class and execute it. Upon execution, you will see that the folder htmlreports are created inside the target folder.

Step 3:

Access the folder and look for the index.html file; that is the file which contains the test results in HTML format.



Step 4:

Open the index.html to view the report. The report created will be similar to the image below.


We can also generate JSON report by using below code:

@CucumberOptions(
features = "src/test/resources/BDDTests",
glue= {"stepDefinitions"},
plugin = { "pretty", "json:target/bddCucumber-reports/Cucumber.json" },
monochrome = true
)


************************************************

✍️AUTHORLinkedIn Profile

************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employee and LIVE Doubt Session 

SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

For more details whatsapp : https://lnkd.in/dnBWDM33



*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


 

No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...