Integration of Allure Report with Rest Assured and TestNG


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

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


  1. Java 11 installed
  2. Maven installed
  3. Eclipse or IntelliJ installed

This framework consists of:

  1. Java 11
  2. Maven – 3.8.1
  3. Allure Report – 2.14.0
  4. Rest Assured – 4.4.0
  5. Allure Rest Assured – 2.14.0
  6. Allure TestNG – 2.14.0
  7. Aspectj – 1.9.6

Implementation Steps

  1. Update Properties section in Maven pom.xml
  2. Add Rest Assured, Allure-Rest Assured and Allure-TetNG dependencies in POM.xml
  3. Update Build Section of pom.xml in Allure Report Project.
  4. Create the Test Code for the testing of REST API under src/test/java
  5. Create TestNG.xml for the project
  6. Run the Tests and Generate Allure Report

Step 1 – Update Properties section in Maven pom.xml


Step 2 – Add the Allure-Rest Assured dependency

 <!--Allure Reporting Dependency-->   

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


     <!-- Allure TestNG Dependency -->
   <!-- Rest Assured Dependency -->

    <!-- Jackson Dependency -->

    <!-- JSON Dependency -->

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

                    <source>${maven.compiler.source}</source> <!--For JAVA 8 use 1.8-->
                    <target>${}</target> <!--For JAVA 8 use 1.8-->

            <!-- -->

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

To see our request and response in more detail using Rest Assured, 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())
@Epic("REST API Regression Testing using TestNG")
@Feature("Verify CRUID Operations on Employee module")
public class EmployeeDetailsTest {

	String BaseURL = "";

	@Test(description = "GET Request Operation")
	@Story("GET Request with Valid User")
	@Description("Test Description : Verify the details of employee of id-2")
	public void verifyUser() {

		// GIVEN
               .filter(new AllureRestAssured())

		// WHEN
               .get(BaseURL + "/v1/employee/2")
        // THEN
                .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(description = "GET Request Operation")
	@Story("GET Request with Invalid User")
	@Description("Test Description : Verify the details of employee of id-99999")
	public void verifyInvalidUser() {

		// Given
              .filter(new AllureRestAssured())

		// WHEN
              .get(BaseURL + "/v1/employee/99999")
        // THEN
               .statusLine("HTTP/1.1 200 OK")
			   .body("message", equalTo("Successfully! Record has not been fetched."));

	@Test(description = "POST Request Operation")
	@Story("POST Request")
	@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");

              .filter(new AllureRestAssured())

	    // WHEN
               .post(BaseURL + "/v1/create")

		// THEN
               .body("data.employee_name", equalTo("APITest"))
			   .body("message", equalTo("Successfully! Record has been added."));



Step 5 – Create testng.xml for the project

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">
<suite name="Suite">
  <test thread-count="5" name="Test">
      <class name="com.example.RestAssuredTestNGAllureReport.EmployeeDetailsTest"/>
  </test> <!-- Test -->
</suite> <!-- Suite -->

Step 6 – 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 two tests failed and one passed out of three tests.

This will create the allure-results folder with all the test reports. These files will be used to generate the 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

The overview page hosts several default widgets representing the basic characteristics of your project and 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.

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.

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!!


2 thoughts on “Integration of Allure Report with Rest Assured and TestNG

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s