Allure Report:
· Allure Report is an open-source multi-language test reporting tool.
· Allure Report is a popular framework used for generating customizable and visually appealing reports for test results.
· It provides detailed insights into the test execution, making it easier to analyze test outcomes.
· Allure works well with various testing frameworks, including JUnit, TestNG, Cucumber, and others.
Pre-requisite: (For Windows)
· First check installed on Windows: Open command prompt, Use command: allure –version
If you got below results:
1. Need to install Allure Results on Windows
2. Allure Results is already Installed successfully
How to install Allure Results on Windows:
1. Ensure Java version 8 or above is installed in the system first, and its directory is specified in the JAVA_HOME environment variable.
2. Go to the latest Allure Report release on GitHub and download the allure-*.zip or allure-*.tgz archive.
3. Open the downloaded file and extract it in the folder of your choice
4. Go inside the folder until you reach bin and copy the
5. Go to settings-> System->About
· On the Advanced tab, click Environment variables.
· In System variables list, double-click the Path variable to open the editing dialog.
· In the Edit environment variable dialog, click New to add a new line entry to the paths list. In the new line, specify the full path to the bin subdirectory from an earlier step, for example:
· C:\Users\pavit\Downloads\allure-2.32.0.zip\allure-2.32.0\bin
· Click OK to save the changes.
Now, Open command prompt, use command: allure –version you will find the version installed there as below
How to add Allure report in TestNG Framework
Step1: Create Maven project and Add maven dependency
· Go to https://mvnrepository.com/ and search ,add following dependencies in pom.xml under<dependencies> </dependencies> tag and save the pom.xml
1. Testng
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.29.1</version>
</dependency>
· Update the maven project
Step 2: Download Allure for windows and set path
· Using above specified methods, already done installing allure for windows.
Step 3: Create a class with test case and create testng.xml and run testng.xml
· Create class with testcase ‘@Test’
· Convert the testcase to generate test suite by
- Right Click (testclass)->TESTN->convert to TESTNG
· Run testng.xml
- Right click (anywhere in testng.xml)->Run As->TestNG suite
- Refresh the project, you will see allure-results folder in project level
Step 4: Use run command to generate allure reports
- To view results right click (allure-results)folder->properties
- Click Location->show in system explorer
- Open command prompt from the location by typing cmd in that path
- Now your command prompt will look like this
- Now, type command : allure serve
Now you can view the allure results
How to add Allure report in Cucumber Framework:
Step1: Create a maven project and Add maven dependency
· Go to https://mvnrepository.com/ and search ,add following dependencies in pom.xml under<dependencies> </dependencies> tag and save the pom.xml
Tip: Select cumber-java and Allure-cucumber same version ,here for example both belongs to same version 7
1. Cucumber-java
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.18.1</version>
</dependency>
2.Allure-cucumber 7
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<version>2.29.1</version>
</dependency>
· Update the maven project
Step2: Update the TestRunner file (TestRunner.java)
· Add the below cod in plugin setup
plugin= {"pretty","io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"}
Step3: Create a feature file and step definition file and run the testrunner.java file
· Create a feature file
· Next step is to Create a step definition file for the feature file written
· Run the Project->TestRunner.java ->maven test
- Refresh the project, you will see allure-results folder in project level
Step 4: Use run command to generate allure reports
- To view results right click (allure-results)folder->properties
- Click Location->show in system explorer
- Open command prompt from the location by typing cmd in that path
- Now your command prompt will look like this
- Now, type command : allure serve
Now you can view the allure results in Cucumber Framework
Advantage of using Allure Report
Detailed Test reports-Allure report provide detailed information about each test.
Customizable Reports-Allure report can be customized according to the needs of our project.
we can add custom sections, graphs and charts to the report.
Support Multiple Test Framework-Allure report supports multiple test frameworks including TestNG, cucumber and Junit.
Integration with CI/CD Tools-Allure can be integrated with CI/CD tools such as Jenkins ,CI, etc.
Screenshots and videos-Allure allows you to add screenshots and videos to our test reports, making it to identify issues.
Filtering and sorting-Allure reports can be filtered and sorted by various criteria including test status, name and duration.
Extent Report Generation in Cucumber:
Extent Report:
Extent Reports is a powerful tool for generating detailed and visually appealing test reports.
An Extent Report provides a rich set of features, including interactive charts, screenshots, and logs.
Step1: Create a maven project and Add maven dependency
· Go to https://mvnrepository.com/ and search ,add following dependencies in pom.xml under<dependencies> </dependencies> tag and save the pom.xml
ExtentReports Cucumber7 Adapter
ExtentReports Cucumber7 Adapter
<!-- https://mvnrepository.com/artifact/tech.grasshopper/extentreports-cucumber7-adapter -->
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.14.0</version>
</dependency>
· Update the maven project
Step2: Adding extent.properties and extent-config.xml file in src/test/resources
· Create a new file extent.properties with below code
extent.reporter.spark.start=true
extent.report.spark.config=src/test/resources/extent-config.xml
extent.reporter.spark.out=test-output/SparkReport/
basefolder.name=reports
basefolder.datetimepattern=d-MMM-YY HH-mm-ss
screenshot.dir=screenshot/
screenshot.rel.path=../../screenshot/
extent.reporter.pdf.start=true
extent.reporter.pdf.out=test output/PdfReport/ExtentPdf.pdf
· Save extent.properties file
· Create another file extent-config.xml with below code
<?xml version="1.0" encoding="UTF-8"?> <extentreports> <configuration> <!-- report theme --> <!-- standard, dark --> <theme>standard</theme>
<!-- document encoding --> <!-- defaults to UTF-8 --> <encoding>UTF-8</encoding>
<!-- protocol for script and stylesheets --> <!-- defaults to https --> <protocol>https</protocol>
<!-- title of the document --> <documentTitle>Extent</documentTitle>
<!-- report name - displayed at top-nav --> <reportName>Sample DSAlgo Automation Report</reportName>
<!-- location of charts in the test view --> <!-- top, bottom --> <testViewChartLocation>bottom</testViewChartLocation>
<!-- custom javascript --> <scripts> <![CDATA[ $(document).ready(function() {
}); ]]> </scripts>
<!-- custom styles --> <styles> <![CDATA[
]]> </styles> </configuration> </extentreports> |
· Save extent-config.xml file.
· Update the maven project
Step3: Update the TestRunner file (TestRunner.java)
· Add the below cod in plugin setup
plugin={"pretty","io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm", "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}
· Save the TestRunner.java
· Run the Project->TestRunner.java -> maven test
· Refresh the project and you will see a folder reports with datetime stamp attached to it according to the format specified in extent.properties file .
Sample report: