What is Allure Report?

HOME

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what has been tested in a neat web report form but allows everyone participating in the development process to extract the maximum useful information from the everyday execution of tests.

How Allure Report is generated?

Allure is based on standard xUnit results output but adds some supplementary data. Any report is generated in two steps. During test execution (first step), a small library called adapter attached to the testing framework saves information about executed tests to XML files. We already provide adapters for popular Java, PHP, Ruby, Python, Scala, and C# test frameworks. During report generation (second step), the XML files are transformed into an HTML report. This can be done with a command line tool, a plugin for CI, or a build tool.

Similarly, when we run our tests, every popular test framework generates junit-style XML report or testng style which will be used by Allure to generate HTML report.

In the below example, we use the maven surefire plugin which automatically generates xml test reports and stores them in target/surefire-reports. And these XML files are transformed into an HTML report by Allure.

Allure reports have provided adapters for Java, PHP, Ruby, Python, Scala, and C# test frameworks.

Allure report has the below-mentioned annotation.

@Epic
@Features
@Stories/@Story

We can add Epic, Feature, and Stories annotations to the test to describe the behaviour of the test.

@Severity(SeverityLevel.BLOCKER)@Severity annotation is used in order to prioritize test methods by severity.

@Description(“Regression Testing”) – We can add a detailed description for each test method. To add such a description, use the @Description annotation.

@Step – In order to define steps in Java code, you need to annotate the respective methods with @Step annotation. When not specified, the step name is equal to the annotated method name.

@Attachment – An attachment in Java code is simply a method annotated with @Attachment that returns either a String or byte[], which should be added to the report.

@Link – We can link the tests to Defect Tracker or JIRA Ticket.

Below is an example that shows how to use various Allure Annotations in the Test.

@Epic("Web Application Regression Testing")
@Feature("Login Page Tests")
@Listeners(TestExecutionListener.class)
public class LoginTests extends BaseTest {

	LoginPage objLogin;
	DashboardPage objDashboardPage;

	@Severity(SeverityLevel.NORMAL)
	@Test(priority = 0, description = "Verify Login Page")
	@Description("Test Description : Verify the title of Login Page")
	@Story("Title of Login Page")
	public void verifyLoginPage() {

		// Create Login Page object
		objLogin = new LoginPage(driver);

		// Verify login page text
		objLogin.verifyPageTitle();
	}
}

Install Allure

For Windows, Allure is available from the Scoop command line installer.

Set-ExecutionPolicy RemoteSigned -scope CurrentUser

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')

To install Allure, download and install Scoop, and then execute in the Powershell:

scoop install allure

I have Allure installed, so I’m getting a message – ‘allure’ (2.14.0) is already installed.

To check if you have Allure installed or not, please use the below command in the command line or PowerShell.

allure --version

Sample Allure Report

You can find more information on Allure documentation.

Additional Tutorials on Allure Reports

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! 

Integration of Allure Report with PyTest

Last Updated on

HOME

In this tutorial, we will discuss the Integration of Allure Report with the PyTest.

Table of Contents:

  1. What is an Allure Report?
  2. Prerequisite
  3. Implementation Steps
    1. Install allure-pytest plugin
    2. Create a new project folder and open it in PyCharm
    3. Add the allure-pytest package to the PyCharms
    4. Create the test code
    5. Execute the tests
    6. Generation of allure-results folder
    7. Generate the Allure Report
    8. Allure Report Dashboard
      1. Categories in Allure Report
      2. Suites in Allure Report
      3. Graphs in Allure Report
      4. Timeline in Allure Report
      5. Behaviours of Allure Report
      6. Packages in Allure Report

What is an Allure Report?

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what has been tested in a neat web report form but allows everyone participating in the development process to extract maximum useful information from everyday execution of tests.

From the dev/qa perspective, Allure reports shorten common defect lifecycle: test failures can be divided into bugs and broken tests, also logs, steps, fixtures, attachments, timings, history, and integrations with TMS and bug-tracking systems can be configured, so the responsible developers and testers will have all information at hand.

Prerequisite:

    Implementation Steps:

    Step 1 – Install allure-pytest plugin

    Go to the command prompt and run the below-mentioned command to download the plugin:

    pip install allure-pytest
    

    The below image shows that the plugin is installed successfully.

    Step 3 – Add the allure-pytest package to the PyCharms

    Go to File->Settings ->Project:PageObjectModel_Pytest->Python Interpreter.

    Click on the “+” sign and enter allure-pytest in the search bar. It will show a list of packages. Select the “allure-pytest” package and click on the “Install Package”.

    Once the package is installed, we will see the message that the package is installed successfully, and it can be seen under the package list as shown below:

    Step 4 – Create the test code

    The complete PyTest framework can be found here – Page Object Model Implementation of Python with Selenium – PyTest.

    Step 5 – Execute the tests

    We need the below command to run the PyTest Framework script using the Allure listener.

    pytest --alluredir allure-results
    

    The output of the above program is

    Step 6 – Generation of allure-results folder

    We have the test case passed. It will generate an allure-results folder in the tests directory. This folder contains all the files needed to generate the Allure Report.

    Step 7 – Generate the Allure Report

    To create Allure Report, use the below command

    allure serve allure-results
    

    This will generate the beautiful Allure Test Report as shown below.

    Step 8 – Allure Report Dashboard

    The overview page hosts several default widgets representing the basic characteristics of your project and test environment.

    1. Statistics – overall report statistics.
    2. Launches – if this report represents several test launches, statistics per launch will be shown here.
    3. Behaviours – information on results aggregated according to stories and features.
    4. Executors – information on test executors that were used to run the tests.
    5. History Trend – if tests accumulated some historical data, it’s trend will be calculated and shown on the graph.
    6. Environment – information on the test environment.

    Categories in Allure Report

    The categories tab gives you a way to create custom defect classifications to apply for test results. There are two categories of defects – Product Defects (failed tests) and Test Defects (broken tests).

    Suites in Allure Report

    On the Suites tab a standard structural representation of executed tests, grouped by suites and classes can be found.

    Graphs in Allure Report

    Graphs allow you to see different statistics collected from the test data: statuses breakdown or severity and duration diagrams.

    Timeline in Allure Report

    The timeline tab visualizes retrospective of tests execution, allure adaptors collect precise timings of tests, and here on this tab, they are arranged accordingly to their sequential or parallel timing structure.

    Behaviours of Allure Report

    This tab groups test results according to Epic, Feature, and Story tags.

    Packages in Allure Report

    The packages tab represents a tree-like layout of test results, grouped by different packages.

    That’s it! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

    Gradle Tutorials

    Last Updated On

    HOME

    Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software.
    Gradle runs on the JVM and you must have a Java Development Kit (JDK) installed to use it.
    Several major IDEs allow you to import Gradle builds and interact with them: Android Studio, IntelliJ IDEA, Eclipse, and NetBeans.

    Installation of Gradle

    Chapter 1 How to install Gradle on Windows

    Creation of Gradle project

    Chapter 1 How to create Java Gradle project in Eclipse
    Chapter 2 How to create a Java Gradle project using Command Line
    Chapter 3 How to create Gradle project in IntelliJ
    Chapter 4 How to create Gradle Java project in IntelliJ using Command Line

    Importing of Gradle Project

    Chapter 1 How to import Java Gradle project in Eclipse
    Chapter 2 How to import Java Gradle project in IntelliJ

    Gradle Project in Cucumber

    Chapter 1 How To Create Gradle Project with Cucumber to test Rest API
    Chapter 2 Run Gradle Cucumber Tests from Command Line
    Chapter 3 Gradle Project with Cucumber, Selenium and TestNG
    Chapter 4 Gradle Project with Cucumber, Selenium and JUnit4

    Gradle Project in Serenity

    Chapter 1 Serenity BDD with Gradle and Cucumber for Web Application
    Chapter 2 Serenity BDD with Cucumber and Rest Assured in Gradle
    Chapter 3 Serenity Emailable Report in Gradle

    Gradle Project with Selenium

    Chapter 1 How to create Gradle project with Selenium and TestNG
    Chapter 2 How to create Gradle project with Selenium and JUnit4
    Chapter 3 Gradle – Integration of Selenium and JUnit5

    Gradle Project in Rest API

    Chapter 1 Setup Basic REST Assured Gradle Project In Eclipse IDE

    Allure Reports for Gradle Project

    Chapter 1 Gradle – Allure Report for Selenium and TestNG
    Chapter 2 Gradle – Allure Report for Selenium and JUnit4
    Chapter 3 Gradle – Allure Report for Cucumber, Selenium and TestNG

    Extent Reports for Gradle Project

    Chapter 1 Gradle – Extent Report Version 5 for Cucumber, Selenium, and TestNG

    Gradle with Jenkins

    Chapter 1 Integrate Gradle project with Jenkins
    Chapter 2 How to create Jenkins pipeline for Gradle project

    Integration of Allure Report with Rest Assured and JUnit4

    HOME

    In the previous tutorial, I explained the Allure Report with Cucumber, Selenium and JUnit4. In this tutorial, I will explain how to Integrate Allure Report with Rest Assured and JUnit4.

    The below example covers the implementation of Allure Report for Rest API using Rest Assured, JUnit4, Java, and Maven.

    Prerequisite

    1. Java 11 or above installed
    2. Maven installed
    3. Eclipse or IntelliJ installed
    4. Allure installed

    Dependency List:

    1. Java 17
    2. Maven – 3.9.6
    3. Allure Maven – 2.12.0
    4. Rest Assured – 5.3.4
    5. Allure Rest Assured – 2.25.0
    6. Allure JUnit4 – 2.25.0
    7. Aspectj – 1.9.21
    8. JUnit – 4.13.2

    Implementation Steps

    Step 1 – Update Properties section in Maven pom.xml

    <properties>
            <rest-assured.version>5.4.0</rest-assured.version>
            <junit.version>4.13.2</junit.version>
            <json.version>20231013</json.version>
            <hamcrest.version>1.3</hamcrest.version>
            <allure.maven.version>2.12.0</allure.maven.version>
            <allure.junit.version>2.25.0</allure.junit.version>
            <allure.rest.assured.version>2.25.0</allure.rest.assured.version>
            <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
            <maven.surefire.plugin.version>3.2.3</maven.surefire.plugin.version>
            <maven.compiler.source>17</maven.compiler.source>
            <maven.compiler.target>17</maven.compiler.target>
            <aspectj.version>1.9.21</aspectj.version>
    </properties>
    

    Step 2 – Add the Allure-Rest Assured dependency

    <!--Allure Reporting Dependency-->   
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-rest-assured</artifactId>
        <version>${allure.rest-assured.version}</version>
    </dependency>
    

    Add other dependencies like Rest Assured and Allure-JUnit4 dependencies in POM.xml

    <dependencies>
    
            <!-- Rest-Assured Dependency -->
            <dependency>
                <groupId>io.rest-assured</groupId>
                <artifactId>rest-assured</artifactId>
                <version>${rest-assured.version}</version>
                <scope>test</scope>
            </dependency>
    
            <!-- JUnit4 Dependency -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
    
            <!-- JSON Dependency -->
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${json.version}</version>
            </dependency>
    
            <!-- Allure JUnit Dependency -->
            <dependency>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-junit4</artifactId>
                <version>${allure.junit.version}</version>
            </dependency>
    
            <!-- Allure Rest-assured Dependency-->
            <dependency>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-rest-assured</artifactId>
                <version>${allure.rest.assured.version}</version>
            </dependency>
    
        </dependencies>
    

    Step 3 – Update the Build Section of pom.xml in Allure Report Project

    <build>
            <plugins>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration>
                        <testFailureIgnore>true</testFailureIgnore>
                        <argLine>
                            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        </argLine>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>io.qameta.allure.junit4.AllureJunit4</value>
                            </property>
                        </properties>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
    
                <plugin>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-maven</artifactId>
                    <version>${allure.maven.version}</version>
                    <configuration>
                        <reportVersion>${allure.maven.version}</reportVersion>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    

    Step 4 – Create a Test Code for the testing of REST API under src/test/java

    Rest Assured and Allure Report are two popular tools for testing. Rest Assured is used for API testing and Allure Report is used for creating detailed reports about tests. To see our request and response in more detail using these tools, we need to add a line to our Rest Assured tests. This will provide the request and response details in the report.

    .filter(new AllureRestAssured())
    

    package org.example;
    
    import io.qameta.allure.*;
    import io.qameta.allure.restassured.AllureRestAssured;
    import io.restassured.http.ContentType;
    import org.json.JSONObject;
    import org.junit.Test;
    
    import static io.restassured.RestAssured.given;
    import static org.hamcrest.core.IsEqual.equalTo;
    
    @Epic("REST API Regression Testing using JUnit4")
    @Feature("Verify CRUID Operations on Employee module")
    public class APITests {
    
        String BaseURL = "https://dummy.restapiexample.com/api";
    
    
        @Test
        @Story("GET Request")
        @Severity(SeverityLevel.NORMAL)
        @Description("Test Description : Verify the details of employee of id-2")
        public void getUser() {
    
            // GIVEN
            given()
                    .filter(new AllureRestAssured())
    
                    // WHEN
                    .when()
                    .get(BaseURL + "/v1/employee/2")
    
                    // THEN
                    .then()
                    .statusCode(200)
                    .statusLine("HTTP/1.1 200 OK")
                    // To verify booking id at index 2
                    .body("data.employee_name", equalTo("Garrett Winters!"))
                    .body("message", equalTo("Successfully! Record has been fetched."));
    
        }
    
        @Test
        @Story("POST Request")
        @Severity(SeverityLevel.NORMAL)
        @Description("Test Description : Verify the creation of a new employee")
        public void createUser() {
    
            JSONObject data = new JSONObject();
    
            data.put("employee_name", "APITest");
            data.put("employee_salary", "99999");
            data.put("employee_age", "30");
    
            // GIVEN
            given()
                    .filter(new AllureRestAssured())
                    .contentType(ContentType.JSON)
                    .body(data.toString())
    
                    // WHEN
                    .when()
                    .post(BaseURL + "/v1/create")
    
                    // THEN
                    .then()
                    .statusCode(200)
                    .body("data.employee_name", equalTo("APITest"))
                    .body("message", equalTo("Successfully! Record has been added."));
    
        }
    }
    

    Step 5 – Run the Test and Generate Allure Report

    To run the tests, use the below command

    mvn clean test
    

    The output of the above program is

    This will create allure-results folder with all the test reports. These files will be used to generate Allure Report.

    To create Allure Report, use the below command

    allure serve
    

    This will generate the beautiful Allure Test Report as shown below.

    Allure Report Dashboard

    Categories in Allure Report

    The categories tab gives you a way to create custom defects classifications to apply for test results. There are two categories of defects – Product Defects (failed tests) and Test Defects (broken tests).

    Suites in Allure Report

    On the Suites tab a standard structural representation of executed tests, grouped by suites and classes can be found.

    View test history

    Each time you run the report from the command line with the mvn clean test command, a new result JSON file will get added to the allure-results folder. Allure can use those files to include a historical view of your tests. Let’s give that a try.

    To get started, run mvn clean test a few times and watch how the number of files in the allure-reports folder grows.

    Now go back to view your report. Select Suites from the left nav, select one of your tests and click Retries in the right pane. You should see the history of test runs for that test:

    Graphs in Allure Report

    Graphs allow you to see different statistics collected from the test data: status breakdown or severity and duration diagrams.

    Timeline in Allure Report

    Timeline tab visualizes retrospective of tests execution, allure adaptors collect precise timings of tests, and here on this tab, they are arranged accordingly to their sequential or parallel timing structure.

    Behaviors of Allure Report

    This tab groups test results according to Epic, Feature, and Story tags.

    The below image shows the request body sent and the status code of the response, its body, and header provided by API.

    Packages in Allure Report

    The packages tab represents a tree-like layout of test results, grouped by different packages.

    We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

    Allure Reports

    HOME

    Allure Framework is a lightweight, flexible multi-language test report tool that not only displays a very concise representation of what has been tested in a neat web report form, but also allows everyone involved in the development process to extract the most useful information from everyday test execution.

    Allure Report for Maven Projects

    Chapter 1 What is Allure Report?
    Chapter 2 Integration of Allure Report with Selenium and JUnit4
    Chapter 3 Integration of Allure Report with Selenium and JUnit5
    Chapter 4 Integration of Allure Report with Selenium and TestNG
    Chapter 5 Allure Report with Cucumber, Selenium and JUnit4
    Chapter 6 Allure Report with Cucumber, Selenium and TestNG
    Chapter 7 Integration of Allure Report with Rest Assured and JUnit4
    Chapter 8 Integration of Allure Report with Rest Assured and TestNG
    Chapter 9 Allure Report for Cucumber7, Selenium, and JUnit5
    Chapter 10 Integration of Allure Report with Jenkins

    Allure Report for Gradle Projects

    Chapter 1 Gradle – Allure Report for Selenium and TestNG
    Chapter 2 Gradle – Allure Report for Selenium and JUnit4
    Chapter 3 Gradle – Allure Report for Cucumber, Selenium and TestNG

    Allure Report with Cucumber, Selenium and TestNG

    Last Updated On

    HOME

    In the previous tutorial, I explained the Integration of the Allure Report with Selenium and TestNG. In this tutorial, I will explain how to Integrate Allure Report with Cucumber, Selenium, and TestNG.

    The below example covers the implementation of Allure Reports with Cucumber, Selenium, TestNG, Java, and Maven. Before starting, make sure to install Allure on your machine. Refer to this tutorial to install allure – What is Allure Report?.

    Table of Contents

    1. Prerequisite
    2. Dependency List
    3. Implementation Steps
      1. Update the Properties section in Maven pom.xml
      2. Add Cucumber5, Selenium, TestNG, Allure-Cucumber5, and Allure-TestNG dependencies
      3. Update the Build Section of pom.xml in the Allure Report Project
      4. Create a Feature file
      5. Create the Step Definition class or Glue Code
      6. Create a TestNG Cucumber Runner class
      7. Create testng.xml for the project
      8. Run the Test and Generate Allure Report
    4. Allure Report Dashboard
      1. Categories in Allure Report
      2. Suites in Allure Report
      3. Graphs in Allure Report
      4. Timeline in Allure Report
      5. Behaviours of Allure Report
      6. Packages in Allure Report

    Prerequisite

    1. Java 17 installed
    2. Maven installed
    3. Eclipse or IntelliJ installed
    4. Allure installed

    Dependency List

    1. Selenium – 4.16.1
    2. Java 17
    3. Cucumber – 7.15.0
    4. Maven – 3.9.6
    5. Allure Report – 2.25.0
    6. Allure Maven – 2.12.0
    7. Aspectj – 1.9.21
    8. Maven Compiler Plugin – 3.12.1
    9. Maven Surefire Plugin – 3.2.3

    Implementation Steps

    Step 1 – Update the Properties section in Maven pom.xml

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cucumber.version>7.15.0</cucumber.version>
        <selenium.version>4.16.1</selenium.version>
        <testng.version>7.9.0</testng.version>
        <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>3.2.3</maven.surefire.plugin.version>
        <maven.compiler.source.version>17</maven.compiler.source.version>
        <maven.compiler.target.version>17</maven.compiler.target.version>
        <allure.junit4.version>2.25.0</allure.junit4.version>
        <aspectj.version>1.9.21</aspectj.version>
        <allure.version>2.25.0</allure.version>
        <allure.maven>2.12.0</allure.maven>
    </properties>
    

    Step 2 – Add dependencies to pom.xml

    Add Cucumber, Selenium, TestNG, Allure-Cucumber, and Allure-TestNG dependencies to pom.xml (Maven Project).

    <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-bom</artifactId>
            <version>${allure.version}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
    
    
      <dependencies>
    
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-java</artifactId>
          <version>${cucumber.version}</version>
        </dependency>
    
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-testng</artifactId>
          <version>${cucumber.version}</version>
          <scope>test</scope>
        </dependency>
    
        <!-- Selenium -->
        <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>${selenium.version}</version>
        </dependency>
    
        <!-- TestNG -->
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>${testng.version}</version>
          <scope>test</scope>
        </dependency>
    
        <!--Allure Cucumber Dependency-->
        <dependency>
          <groupId>io.qameta.allure</groupId>
          <artifactId>allure-cucumber7-jvm</artifactId>
          <scope>test</scope>
        </dependency>
    
        <!--Allure Reporting Dependency-->
        <dependency>
          <groupId>io.qameta.allure</groupId>
          <artifactId>allure-testng</artifactId>
          <scope>test</scope>
        </dependency>
    
      </dependencies>
    

    Step 3 – Update the Build Section of pom.xml in the Allure Report Project

    <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
              <source>${maven.compiler.source.version}</source>
              <target>${maven.compiler.target.version}</target>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
              </suiteXmlFiles>
              <argLine>
                -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
              </argLine>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectj.version}</version>
                <scope>runtime</scope>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>${allure.maven}</version>
            <configuration>
              <reportVersion>${allure.maven}</reportVersion>
            </configuration>
          </plugin>
        </plugins>
      </build>
    

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.example</groupId>
      <artifactId>AllureReport_Cucumber_TestNG</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>jar</packaging>
    
      <name>AllureReport_Cucumber_TestNG</name>
      <url>http://maven.apache.org</url>
    
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cucumber.version>7.15.0</cucumber.version>
        <selenium.version>4.16.1</selenium.version>
        <testng.version>7.9.0</testng.version>
        <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>3.2.3</maven.surefire.plugin.version>
        <maven.compiler.source.version>17</maven.compiler.source.version>
        <maven.compiler.target.version>17</maven.compiler.target.version>
        <allure.junit4.version>2.25.0</allure.junit4.version>
        <aspectj.version>1.9.21</aspectj.version>
        <allure.version>2.25.0</allure.version>
        <allure.maven>2.12.0</allure.maven>
      </properties>
    
      <!-- Add allure-bom to dependency management to ensure correct versions of all the dependencies are used -->
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-bom</artifactId>
            <version>${allure.version}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
    
      <dependencies>
    
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-java</artifactId>
          <version>${cucumber.version}</version>
        </dependency>
    
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-testng</artifactId>
          <version>${cucumber.version}</version>
          <scope>test</scope>
        </dependency>
    
        <!-- Selenium -->
        <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>${selenium.version}</version>
        </dependency>
    
        <!-- TestNG -->
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>${testng.version}</version>
          <scope>test</scope>
        </dependency>
    
        <!--Allure Cucumber Dependency-->
        <dependency>
          <groupId>io.qameta.allure</groupId>
          <artifactId>allure-cucumber7-jvm</artifactId>
          <scope>test</scope>
        </dependency>
    
        <!--Allure Reporting Dependency-->
        <dependency>
          <groupId>io.qameta.allure</groupId>
          <artifactId>allure-testng</artifactId>
          <scope>test</scope>
        </dependency>
    
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
              <source>${maven.compiler.source.version}</source>
              <target>${maven.compiler.target.version}</target>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
              </suiteXmlFiles>
              <argLine>
                -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
              </argLine>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectj.version}</version>
                <scope>runtime</scope>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>${allure.maven}</version>
            <configuration>
              <reportVersion>${allure.maven}</reportVersion>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
    
    

    Step 4 – Create a Feature file

    Create a folder – features within src/test/resources to create test scenarios in the Feature file.

    Feature file should be saved as an extension of .feature. Add the test scenarios in this feature file. I have added sample test scenarios. In this feature file. The test scenarios are written in Gherkins language.

    Feature: Login to HRM Application
    
      Background:
        Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
    
      @ValidCredentials
      Scenario: Login with valid credentials
    
        When User enters username as "Admin" and password as "admin123"
        Then User should be able to login successfully and new page open
    
      @InvalidCredentials
      Scenario Outline: Login with invalid credentials
    
        When User enters username as "<username>" and password as "<password>"
        Then User should be able to see error message "<errorMessage>"
    
        Examples:
          | username   | password  | errorMessage                      |
          | Admin      | admin12$$ | Invalid credentials               |
          | admin$$    | admin123  | Invalid credentials               |
          | abc123     | xyz$$     | Invalid credentials               |
          | 234        | xyz$$     | Invalid credentials!              |
    

    Step 5 – Create the Step Definition class or Glue Code

    Below is the code for the Hooks.

    package com.example.definitions;
    
    import io.cucumber.java.After;
    import io.cucumber.java.Before;
    import io.cucumber.java.Scenario;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.TakesScreenshot;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    
    import java.time.Duration;
    
    public class Hooks {
        protected static WebDriver driver;
        public final static int TIMEOUT = 5;
    
        @Before
        public void setUp() {
    
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--start-maximized");
            driver = new ChromeDriver(options);
            driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT));
    
        }
    
        @After
        public void tearDown(Scenario scenario) {
            try {
                String screenshotName = scenario.getName();
                if (scenario.isFailed()) {
                    TakesScreenshot ts = (TakesScreenshot) driver;
                    byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
                    scenario.attach(screenshot, "img/png", screenshotName);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            driver.quit();
        }
    
    }
    

    LoginPageDefinition

    package com.example.definitions;
    
    
    import io.cucumber.java.en.Given;
    import io.cucumber.java.en.Then;
    import io.cucumber.java.en.When;
    
    import org.openqa.selenium.By;
    import org.testng.Assert;
    
    public class LoginPageDefinitions {
    
       Hooks hooks;
    
    
        @Given("User is on HRMLogin page {string}")
        public void loginTest(String url) {
    
            hooks.driver.get(url);
    
        }
    
        @When("User enters username as {string} and password as {string}")
        public void goToHomePage(String userName, String passWord) {
    
            // login to application
            hooks.driver.findElement(By.name("username")).sendKeys(userName);
            hooks.driver.findElement(By.name("password")).sendKeys(passWord);
            hooks.driver.findElement(By.xpath("//*[@class='oxd-form']/div[3]/button")).submit();
    
            // go the next page
        }
    
        @Then("User should be able to login successfully and new page open")
        public void verifyLogin() {
    
            String homePageHeading = hooks.driver.findElement(By.xpath("//*[@class='oxd-topbar-header-breadcrumb']/h6")).getText();
    
            //Verify new page - HomePage
            Assert.assertEquals(homePageHeading,"Dashboard");
    
        }
    
        @Then("User should be able to see error message {string}")
        public void verifyErrorMessage(String expectedErrorMessage) {
    
            String actualErrorMessage = hooks.driver.findElement(By.xpath("//*[@class='orangehrm-login-error']/div[1]/div[1]/p")).getText();
    
            // Verify Error Message
            Assert.assertEquals(actualErrorMessage, expectedErrorMessage);
    
        }
    
    }
    

    Step 6 – Create a TestNG Cucumber Runner class

    We need to create a class called Runner class to run the tests. This class will use the TestNG annotation @Test, which tells TestNG what is the test runner class.

    package com.example.runner;
    
    import org.testng.annotations.Test;
    import io.cucumber.testng.AbstractTestNGCucumberTests;
    import io.cucumber.testng.CucumberOptions;
    
    
    @Test
    @CucumberOptions(tags = "", features = {"src/test/resources/features"}, glue = {"com.example.definitions"},
            plugin = {"pretty","io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"})
    
    public class CucumberRunnerTests extends AbstractTestNGCucumberTests{
    
    }
    

    Note:- @Test annotation marks this class as part of the test. So, if we will remove this annotation, the Allure Report executes CucumberRunnerTests as a separate test suite, so there will be duplicate results.

    Step 7 – Create testng.xml for the project

    <?xml version = "1.0"encoding = "UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name = "Suite1">
        <test name = "Test Demo">
            <classes>
                <class name = "com.example.runner.CucumberRunnerTests"/>
            </classes>
        </test>
    </suite>
    

    Step 8 – Run the Test and Generate Allure Report

    To run the tests, use the below command

    mvn clean test
    

    In the below image, we can see that one test failed and four passed out of five tests.

    This will create the allure-results folder with all the test reports within target folder. These files will be used to generate Allure Report.

    Use the below command to generate the Allure Report

    allure serve
    

    This will generate the beautiful Allure Test Report as shown below.

    Allure Report Dashboard

    Categories in Allure Report

    The categories tab gives you a way to create custom defect classifications to apply for test results. There are two categories of defects – Product Defects (failed tests) and Test Defects (broken tests).

    Suites in Allure Report

    On the Suites tab a standard structural representation of executed tests, grouped by suites and classes can be found. Here, we have 2 suits – Feature and Surefire test. Surefire tests are executed from CucumberRunnerTests.

    Graphs in Allure Report

    Graphs allow you to see different statistics collected from the test data: status breakdown or severity and duration diagrams.

    Timeline in Allure Report

    The timeline tab visualizes retrospective test execution, allure adaptors collect precise timings of tests, and here on this tab, they are arranged accordingly to their sequential or parallel timing structure.

    Behaviours of Allure Report

    This tab groups test results according to Epic, Feature, and Story tags.

    Screenshot attached to the failed test case

    Packages in Allure Report

    The packages tab represents a tree-like layout of test results, grouped by different packages.

    When we don’t use @Test in CucumberRunnerTests.java, then as mentioned above the Allure report will have duplicate details.

    Congratulations!! We have integrated an allure report with Cucumber, Selenium, and TestNG. I hope this tutorial is useful to you.

    Additional Tutorials on Allure Reports

    Integration of Allure Report with Selenium and JUnit4
    Integration of Allure Report with Selenium and TestNG
    Gradle – Allure Report for Selenium and JUnit4
    Gradle – Allure Report for Cucumber, Selenium and TestNG
    Integration of Allure Report with Rest Assured and JUnit4

    Allure Report with Cucumber, Selenium and JUnit4

    HOME

    In the previous tutorial, I have explained the Integration of the Allure Report with Selenium and JUnit4. In this tutorial, I will explain how to Integrate Allure Report with Cucumber7 and JUnit4.

    Below example covers the implementation of Allure Reports in Selenium using JUnit4, Java and Maven.

    1. Prerequisite
    2. Dependency List
    3. Project Structure
    4. Implementation Steps
      1. Update Properties section in Maven pom.xml
      2. Add dependencies to POM.xml
      3. Update Build Section of pom.xml in Allure Report Project
      4. Create Feature file in src/test/resources
      5. Create the Step Definition class or Glue Code
      6. Create a Cucumber Runner class
      7. Create allure.properties in src/test/resources
      8. Run the Test and Generate Allure Report
      9. Generate Allure Report

    Prerequisite

    1. Java 11 or above installed
    2. Maven installed
    3. Eclipse or IntelliJ installed
    4. Allure installed and configured

    Dependency List:

    1. Selenium – 4.16.1
    2. Java 17
    3. Cucumber – 7.15.0
    4. Maven – 3.9.5
    5. Allure BOM – 2.25.0
    6. Aspectj – 1.9.21
    7. Allure Maven – 2.12.0
    8. JUnit – 4.13.2

    Implementation Steps

    Step 1 – Update Properties section in Maven pom.xml

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cucumber.version>7.15.0</cucumber.version>
        <selenium.version>4.16.1</selenium.version>
        <junit.version>4.13.2</junit.version>
        <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>3.2.3</maven.surefire.plugin.version>
        <maven.compiler.source.version>17</maven.compiler.source.version>
        <maven.compiler.target.version>17</maven.compiler.target.version>
        <allure.junit4.version>2.25.0</allure.junit4.version>
        <aspectj.version>1.9.21</aspectj.version>
        <allure.version>2.25.0</allure.version>
        <allure.maven>2.12.0</allure.maven>
     </properties>
    

    Step 2 – Add dependencies to POM.xml

     <dependencies>
         
         <!--Cucumber Dependencies-->     
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-java</artifactId>
          <version>${cucumber.version}</version>
        </dependency>
        
        <dependency>
          <groupId>io.cucumber</groupId>
          <artifactId>cucumber-junit</artifactId>
          <version>${cucumber.version}</version>
           <scope>test</scope>
        </dependency>
     
       <!--Selenium Dependency-->
        <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>${selenium.version}</version>
        </dependency>   
    
       <!--Hamcrest Dependency-->
        <dependency>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest</artifactId>
          <version>2.2</version>
          <scope>test</scope>
        </dependency>
        
       <!--Allure Cucumber Dependency-->     
          <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-cucumber5-jvm</artifactId>
            <version>${allure.cucumber5.version}</version>
        </dependency>
        
         <!--Allure Reporting Dependency-->     
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit4</artifactId>
            <version>${allure.junit4.version}</version>
            <scope>test</scope>
        </dependency>
    
      </dependencies>
    

    Step 3 – Update Build Section of pom.xml in Allure Report Project

    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>${maven.compiler.source.version}</source>
                        <target>${maven.compiler.target.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration>
                        <argLine>
                            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        </argLine>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-maven</artifactId>
                    <version>${allure.maven}</version>
                    <configuration>
                        <reportVersion>${allure.maven}</reportVersion>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>AllureReport_Cucumber_JUnit4</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>AllureReport_Cucumber_JUnit4</name>
        <url>http://maven.apache.org</url>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <cucumber.version>7.15.0</cucumber.version>
            <selenium.version>4.16.1</selenium.version>
            <junit.version>4.13.2</junit.version>
            <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
            <maven.surefire.plugin.version>3.2.3</maven.surefire.plugin.version>
            <maven.compiler.source.version>17</maven.compiler.source.version>
            <maven.compiler.target.version>17</maven.compiler.target.version>
            <allure.junit4.version>2.25.0</allure.junit4.version>
            <aspectj.version>1.9.21</aspectj.version>
            <allure.version>2.25.0</allure.version>
            <allure.maven>2.12.0</allure.maven>
        </properties>
    
        <!-- Add allure-bom to dependency management to ensure correct versions of all the dependencies are used -->
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-bom</artifactId>
                    <version>${allure.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
    
        <dependencies>
    
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-java</artifactId>
                <version>${cucumber.version}</version>
            </dependency>
    
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-junit</artifactId>
                <version>${cucumber.version}</version>
                <scope>test</scope>
            </dependency>
    
            <!-- Selenium -->
            <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-java</artifactId>
                <version>${selenium.version}</version>
            </dependency>
    
            <!-- JUnit4 -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
    
            <!--Allure Cucumber Dependency-->
            <dependency>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-cucumber7-jvm</artifactId>
                <scope>test</scope>
            </dependency>
    
            <!--Allure Reporting Dependency-->
            <dependency>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-junit4</artifactId>
                <scope>test</scope>
            </dependency>
    
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>${maven.compiler.source.version}</source>
                        <target>${maven.compiler.target.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration>
                        <argLine>
                            -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        </argLine>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.aspectj</groupId>
                            <artifactId>aspectjweaver</artifactId>
                            <version>${aspectj.version}</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>io.qameta.allure</groupId>
                    <artifactId>allure-maven</artifactId>
                    <version>${allure.maven}</version>
                    <configuration>
                        <reportVersion>${allure.maven}</reportVersion>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    

    Step 4 – Create Feature file in src/test/resources

    Create source folder – src/test/resources and features folder within src/test/resources to create test scenarios in Feature file. Feature file should be saved as an extension of .feature. Add the test scenarios in this feature file. I have added sample test scenarios. In this feature file, I have created a scenario for successful login and one Scenario Outline for failed login. The test scenarios are written in Gherkins language.

    Feature: Login to HRM Application
    
      Background:
        Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
    
      @ValidCredentials
      Scenario: Login with valid credentials
    
        When User enters username as "Admin" and password as "admin123"
        Then User should be able to login successfully and new page open
    
      @InvalidCredentials
      Scenario Outline: Login with invalid credentials
    
        When User enters username as "<username>" and password as "<password>"
        Then User should be able to see error message "<errorMessage>"
    
        Examples:
          | username   | password    | errorMessage                      |
          | Admin        | admin12$$ | Invalid credentials               |
          | admin$$     | admin123   | Invalid credentials               |
          | abc123       | xyz$$          | Invalid credentials               |
          | 234             | xyz$$         | Invalid credentials!              |
    

    Step 5 – Create the Step Definition class or Glue Code

    package com.example.definitions;
    
    import io.cucumber.java.en.Given;
    import io.cucumber.java.en.Then;
    import io.cucumber.java.en.When;
    import org.junit.Assert;
    import org.openqa.selenium.By;
    
    public class LoginPageDefinitions {
    
       Hooks hooks;
    
        @Given("User is on HRMLogin page {string}")
        public void loginTest(String url) {
    
            hooks.driver.get(url);
    
        }
    
        @When("User enters username as {string} and password as {string}")
        public void goToHomePage(String userName, String passWord) {
    
            // login to application
            hooks.driver.findElement(By.name("username")).sendKeys(userName);
            hooks.driver.findElement(By.name("password")).sendKeys(passWord);
            hooks.driver.findElement(By.xpath("//*[@class='oxd-form']/div[3]/button")).submit();
    
            // go the next page
        }
    
        @Then("User should be able to login successfully and new page open")
        public void verifyLogin() {
    
            String homePageHeading = hooks.driver.findElement(By.xpath("//*[@class='oxd-topbar-header-breadcrumb']/h6")).getText();
    
            //Verify new page - HomePage
            Assert.assertEquals("Dashboard",homePageHeading);
    
        }
    
        @Then("User should be able to see error message {string}")
        public void verifyErrorMessage(String expectedErrorMessage) {
    
            String actualErrorMessage = hooks.driver.findElement(By.xpath("//*[@class='orangehrm-login-error']/div[1]/div[1]/p")).getText();
    
            // Verify Error Message
            Assert.assertEquals(expectedErrorMessage,actualErrorMessage);
    
        }
    
    }
    

    Hook.java

    package com.example.definitions;
    
    import io.cucumber.java.After;
    import io.cucumber.java.Before;
    import io.cucumber.java.Scenario;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.TakesScreenshot;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    
    import java.time.Duration;
    
    public class Hooks {
        protected static WebDriver driver;
        public final static int TIMEOUT = 5;
    
        @Before
        public void setUp() {
    
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--start-maximized");
            driver = new ChromeDriver(options);
            driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT));
    
        }
    
        @After
        public void tearDown(Scenario scenario) {
            try {
                String screenshotName = scenario.getName();
                if (scenario.isFailed()) {
                    TakesScreenshot ts = (TakesScreenshot) driver;
                    byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
                    scenario.attach(screenshot, "img/png", screenshotName);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            driver.quit();
        }
    }
    

    Step 6 – Create a Cucumber Runner class

    We need to create a class called Runner class to run the tests. This class will use the JUnit annotation @RunWith(), which tells JUnit what is the test runner class.

    package com.example.runner;
    
    import org.junit.runner.RunWith;
    import io.cucumber.junit.Cucumber;
    import io.cucumber.junit.CucumberOptions;
    
    @RunWith(Cucumber.class)
    @CucumberOptions(tags = "", features = {"src/test/resources/features"}, glue = {"com.example.definitions"},
            plugin = {"pretty","io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"})
    
    public class CucumberRunnerTests  {
    
    }
    

    allure.results.directory=target/allure-results
    

    Step 8 – Run the Test and Generate Allure Report

    To run the tests, use the below command

    mvn clean test
    

    In the below image, we can see that one test is failed and four passed out of five tests.

    This will create allure-results folder with all the test report. These files will be use to generate Allure Report.

    Change current directory to target directory and then use the below command to generate the Allure Report

    allure serve
    

    This will generate the beautiful Allure Test Report as shown below.

    Allure Report Dashboard

    It shows detail of all the test steps and the screenshot of the failed test step also as shown below.

    Categories in Allure Report

    Categories tab gives you the way to create custom defects classification to apply for test results. There are two categories of defects – Product Defects (failed tests) and Test Defects (broken tests).

    Suites in Allure Report

    On the Suites tab a standard structural representation of executed tests, grouped by suites and classes can be found.

    Graphs in Allure Report

    Graphs allow you to see different statistics collected from the test data: statuses breakdown or severity and duration diagrams.

    Timeline in Allure Report

    Timeline tab visualizes retrospective of tests execution, allure adaptors collect precise timings of tests, and here on this tab they are arranged accordingly to their sequential or parallel timing structure.

    Behaviors of Allure Report

    This tab groups test results according to Epic, Feature and Story tags.

    Packages in Allure Report

    Packages tab represents a tree-like layout of test results, grouped by different packages.

    TestNG Tutorials

    HOME

    Chapter 1 TestNG Annotations
    Chapter 2 Assertions in TestNG
    Chapter 3 Hard Assert and Soft Assert
    Chapter 4 How to create and run TestNG.xml of a TestNG class
    Chapter 5 How to pass Parameters in TestNG
    Chapter 6 Prioritizing Test Cases in TestNG: Complete Guide
    Chapter 7 How to disable Selenium Test Cases using TestNG Feature – @Ignore
    Chapter 8 How to Use dependsOnMethods() in TestNG for Selenium Test Case Dependency
    Chapter 9 How to group Tests in Selenium
    Chapter 10 InvocationCount in TestNG
    Chapter 11 How to run Parallel Tests in Selenium with TestNG
    Chapter 12 Cross Browser Testing using Selenium and TestNG
    Chapter 13 Screenshot of Failed Test Cases in Selenium WebDriver
    Chapter 14 TestNG Listeners in Selenium
    Chapter 15 How to Retry failed tests in TestNG – IRetryAnalyzer
    Chapter 16 DataProviders in TestNG
    Chapter 17 DataProvider in TestNG using Excel
    Chapter 18 Parallel testing of DataProviders in TestNG
    Chapter 19 TestNG Interview Questions

    Category 4: Test Framework

    Chapter 1 Integration of REST Assured with TestNG
    Chapter 2 Integration of Cucumber with Selenium and TestNG
    Chapter 3 Integration Testing of Springboot with Cucumber and TestNG

    Gradle

    Chapter 1 How to create Gradle project with Selenium and TestNG
    Chapter 2 Gradle Project with Cucumber, Selenium and TestNG

    Category 5: Reporting with TestNG

    Chapter 1 Gradle – Allure Report for Selenium and TestNG
    Chapter 2 Gradle – Allure Report for Cucumber, Selenium and TestNG
    Chapter 3 Integration of Allure Report with Rest Assured and TestNG
    Chapter 4 Gradle – Allure Report for Selenium and TestNG

    ExtentReports with TestNG

    Chapter 1 ExtentReports Version 5 for Cucumber 6 and TestNG
    Chapter 2 PDF ExtentReport for Cucumber and TestNG
    Chapter 3 ExtentReports Version 5 for Cucumber 7 and TestNG

    Jenkins Tutorial

    HOME

    Jenkins is a self-contained, open-source automation server that can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.

    Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.

    Chapter 1 What is Jenkins?
    Chapter 2 How to install Jenkins on Windows 10
    Chapter 3 How to configure Java and Maven in Jenkins
    Chapter 4 Integration Of Jenkins With Selenium WebDriver
    Chapter 5 How to install Maven Plugin in Jenkins
    Chapter 6 How to install Plugins from Jenkins CLI?
    Chapter 7 Integrate Gradle project with Jenkins
    Chapter 8 How to install Plugins in Jenkins
    Chapter 9 How to Schedule a Jenkins Job
    Chapter 10 Build History Metrics in Jenkins
    Chapter 11 How to install the trends-related plugin in Jenkins?
    Chapter 12 How to run parameterized Selenium tests in Jenkins

    Reports in Jenkins

    Chapter 1 How to generate TestNG Report in Jenkins
    Chapter 2 How to create JUnit Report in Jenkins
    Chapter 3 Integration of Allure Report with Jenkins
    Chapter 4 How to generate HTML Reports in Jenkins
    Chapter 5 Integration of Cucumber Report with TestNG in Jenkins
    Chapter 6 Serenity with Jenkins
    Chapter 7 How to publish ExtentReport using Jenkins

    Jenkins Pipeline

    Chapter 1 Jenkins Pipeline
    Chapter 2 How to create Jenkins pipeline for Selenium tests
    Chapter 3 How to create Jenkins pipeline for Serenity tests
    Chapter 4 How to create Jenkins pipeline for Cucumber tests
    Chapter 5 How to create Jenkins pipeline for Extent Report
    Chapter 6 How to create Jenkins pipeline for Gradle project

    CI/CD

    Chapter 1 Integration of GitHub with Jenkins
    Chapter 2 Jenkins GitLab Integration

    Cucumber Tutorials

     HOME

    Cucumber Introduction, Installation, and Configuration

    Chapter 1  Introduction of Cucumber Testing Tool (BDD Tool)
    Chapter 2 How to install Cucumber Eclipse Plugin
    Chapter 3 How to setup Cucumber with Eclipse
    Chapter 4 Cucumber – What is Gherkin

    Cucumber Scenario, Features & Step Definition

    Chapter 1 Cucumber – What is Feature File in Cucumber
    Chapter 2 Step Definition in Cucumber
    Chapter 3 Cucumber – JUnit Test Runner Class

    Cucumber – Hooks & Tags

    Chapter 1 Hooks in Cucumber
    Chapter 2 Tags in Cucumber
    Chapter 3 Conditional Hooks in Cucumber
    Chapter 4 What is CucumberOptions in Cucumber?
    Chapter 5 Background in Cucumber
    Chapter 6 Monochrome in Cucumber
    Chapter 7 What is Glue in Cucumber?

    Cucumber – Data Driven Testing

    Chapter 1 Data Driven Testing using Scenario Outline in Cucumber
    Chapter 2 DataTables in Cucumber

    Cucumber Integration with Selenium – Maven

    Chapter 1 Integration of Cucumber with Selenium and JUnit4
    Chapter 2 Integration of Cucumber with Selenium and TestNG
    Chapter 3 Page Object Model with Selenium, Cucumber and JUnit
    Chapter 4 Page Object Model with Selenium, Cucumber, and TestNG
    Chapter 5 Integration of Cucumber7 with Selenium and JUnit5
    Chapter 6 Run Cucumber7 with JUnit5 Tests from Maven Command Line
    Chapter 7 How to rerun failed tests in Cucumber
    Chapter 8 How to create Cucumber Report after rerun of failed tests – NEW
    Chapter 9 How to rerun failed tests twice in Cucumber – NEW

    Cucumber – Command Line Execution

    Chapter 1 Run Cucumber Test from Command Line
    Chapter 2 Run Gradle Cucumber Tests from Command Line

    Cucumber Integration with Rest API

    Chapter 1 Rest API Test in Cucumber BDD
    Chapter 2 How To Create Gradle Project with Cucumber to test Rest API

    Cucumber Integration with SpringBoot

    Chapter 1 Integration Testing of Springboot with Cucumber and JUnit4
    Chapter 2 Integration Testing of Springboot with Cucumber and TestNG

    Cucumber – Reporting

    Chapter 1 Cucumber Tutorial – Cucumber Reports
    Chapter 2 Cucumber Report Service
    Chapter 3 Implemention of ‘Masterthought’ Reports in Cucumber
    Chapter 4 Implemention of ‘Masterthought’ Reports in Cucumber with JUnit4

    Cucumber Integration with Allure Reports

    Chapter 1 Allure Report with Cucumber5, Selenium and JUnit4
    Chapter 2 Allure Report with Cucumber5, Selenium and TestNG
    Chapter 3 Integration of Allure Report with Rest Assured and JUnit4
    Chapter 4 Integration of Allure Report with Rest Assured and TestNG
    Chapter 5 Gradle – Allure Report for Selenium and TestNG

    Cucumber Integration with Extent Reports

    Chapter 1 ExtentReports Version 5 for Cucumber 6 and TestNG
    Chapter 2 How to add Screenshot to Cucumber ExtentReports
    Chapter 3 ExtentReports Version 5 for Cucumber 6 and JUnit4
    Chapter 4 PDF ExtentReport for Cucumber and TestNG
    Chapter 5 ExtentReports Version 5 for Cucumber 7 and TestNG
    Chapter 6 Extent Reports Version 5 for Cucumber7 and JUnit5

    Cucumber – Parallel Execution

    Chapter 1 Parallel Testing in Cucumber with JUnit
    Chapter 2 Parallel Testing in Cucumber with TestNG
    Chapter 3 Dependency Injection in Cucumber using Pico-Container