Integration of Allure Report with Rest Assured and JUnit4


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

Below example covers the implementation of Allure Report for Rest API using Rest Assured ,JUnit4, 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 JUnit4 – 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-JUnit4 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. 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-JUnit4 dependencies in POM.xml
   <!-- Rest Assured Dependency -->

    <!-- Jackson Dependency -->

    <!-- JSON Dependency -->


Step 3 – Update 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 Test Code for the testing of REST API under src/test/java

Rest Assured and Allure Report is two popular tool for testing.Rest Assured is using for API testing and Allure Report is using for create detailed reports about tests.To see our request and response more detailed using this 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())
@Epic("REST API Regression Testing using JUnit4")
@Feature("Verify CRUID Operations on Employee module")
public class EmployeeDetailsTest {

	String BaseURL = "";

	@Story("GET Request")
	@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."));

	@Story("POST Request")
	@Description("Test Description : Verify the creation of a new employee")
	public void createUser() {

		JSONObject data = new JSONObject();

		// Map<String, String> map = new HashMap<String, String>();

		data.put("employee_name", "APITest");
		data.put("employee_salary", "99999");
		data.put("employee_age", "30");

		// GIVEN
               .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 – Run the Test and Generate Allure Report

To run the tests, use the below command

mvn clean test

This will create allure-results folder with all the test report. These files will be use 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

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.

View test history

Each time you run the report from the command line with the mvn clean test command, new result json file will get added in 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 time and watch how the number of file 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 cick Retries in the right pane. You should see history of test runs for that test:

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.

Below image show the request body sent and the status code of response, its body and header provided by API.

Packages in Allure Report

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

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s