A Step-by-Step Guide
REST Assured is one of the most popular Java libraries for testing REST APIs, thanks to its readable, fluent syntax for sending requests and validating responses. But its default console output only tells you so much when a test fails deep in a chain of API calls. This is where Allure report generation for REST Assured test framework setups becomes genuinely useful. Allure converts your API test results into an interactive HTML report with full request/response logs, step-level detail, and historical trends.
In this guide, you’ll learn how to add Allure reporting to a REST Assured project built with Maven and TestNG.
Why Use Allure with REST Assured?
Before jumping into setup, here’s why teams pair Allure with REST Assured instead of relying on default TestNG or Surefire output:
- Full request/response logging – see the exact headers, payload, and status code for every API call.
- Step-by-step breakdown – trace which validation or assertion failed within a test.
- Filterable dashboard – sort tests by status, severity, endpoint, or feature.
- CI/CD friendly – generates static HTML that plugs neatly into Jenkins, GitHub Actions, or GitLab pipelines.
Now let’s walk through the setup step by step.
Step 1: Add the Required Dependencies to Your Maven Project
You’ll need REST Assured itself, TestNG as the test runner, and the Allure TestNG adapter. Add these to your pom.xml:
<dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>5.5.0</version></dependency><dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.10.2</version></dependency><dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-testng</artifactId> <version>2.29.0</version></dependency>
If your framework uses JUnit 5 instead, swap allure-testng for allure-junit5 and configure it the same way.
Step 2: Add the Allure REST Assured Filter
Unlike UI test frameworks, REST Assured has a dedicated Allure module that automatically logs request and response details as attachments. Add it to your pom.xml:
<dependency> <groupId>io.qameta.allure</groupId> <artifactId>allure-rest-assured</artifactId> <version>2.29.0</version></dependency>
Then register the filter on your RequestSpecification so every call gets logged automatically:
import static io.restassured.RestAssured.given;import io.qameta.allure.restassured.AllureRestAssured;given() .filter(new AllureRestAssured()) .baseUri("https://api.example.com") .when() .get("/users/1") .then() .statusCode(200);
With this filter in place, every request URL, header, and response body is automatically attached to the corresponding step in your Allure report, no manual logging required.
Step 3: Configure the Aspect Weaver
Allure uses AspectJ to capture @Step annotations at runtime. Add the AspectJ weaver as a Java agent in your Surefire plugin configuration:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.2.5</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/1.9.22/aspectjweaver-1.9.22.jar" </argLine> </configuration></plugin>
Then add the AspectJ weaver dependency itself:
<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.22</version></dependency>
Step 4: Install the Allure CLI Tool
The Maven dependencies generate raw result data, but you also need the Allure command-line tool installed to turn that data into an actual HTML report.
On Windows (via Scoop):
scoop install allure
On Mac (via Homebrew):
brew install allure
On Linux, Allure can be installed manually or via a package manager like apt after adding the correct repository.
Step 5: Run Your REST Assured Tests
Run your API test suite through Maven as usual:
mvn clean test
By default, Allure writes its raw result files (JSON and attachments) to target/allure-results. This location can be customized in your pom.xml, but the default works fine for most projects.
Step 6: View the Report Instantly with Allure Serve
To quickly review results right after a test run, use allure serve:
allure serve target/allure-results
This spins up a temporary local server, builds the report on the fly, and opens it in your default browser. It’s the fastest way to inspect API test results during local development.
Step 7: Generate a Static Report for Deployment
For CI/CD pipelines or sharing results with your team, generate a permanent static report instead:
allure generate target/allure-results -o target/allure-report --clean
Breaking this down:
target/allure-resultsis the source folder with raw result data.-o target/allure-reportsets the output folder for the generated HTML report.--cleanclears any previous report before building a fresh one.
The resulting target/allure-report folder is fully self-contained. Publish it as a build artifact, host it internally, or link it from your CI dashboard.
Bonus: Adding Custom Steps for Better Readability
Beyond automatic request/response logging, you can break down complex API test flows into named steps using the @Step annotation. This makes multi-call test scenarios much easier to follow in the report:
import io.qameta.allure.Step;public class UserApiTest { @Step("Create a new user") public Response createUser(String payload) { return given() .filter(new AllureRestAssured()) .contentType("application/json") .body(payload) .when() .post("/users"); } @Step("Verify user was created successfully") public void verifyUserCreated(Response response) { response.then().statusCode(201); }}
Each @Step shows up as a distinct, labeled entry in the report, so anyone reviewing a failed test can immediately see which stage of the API flow broke down.
Putting It All Together
Here’s the complete workflow in one place:
# pom.xml: add rest-assured, testng, allure-testng, allure-rest-assured, and aspectjweaver dependenciesscoop install allure # Windowsbrew install allure # Macmvn clean testallure serve target/allure-resultsallure generate target/allure-results -o target/allure-report --clean
Once this is wired into your CI pipeline, every REST Assured run automatically produces both raw result data and a polished, shareable HTML report with full API call details.
Final Thoughts
Setting up Allure report generation for REST Assured test framework projects takes a bit of Maven configuration upfront, but it pays off quickly: complete request/response logs, clearly labeled test steps, and reports that make debugging failed API tests far less painful. Whether you’re checking results locally with allure serve or publishing static reports from your CI pipeline, Allure gives your REST Assured suite a reporting layer that scales as your API test coverage grows.
If your team is already using REST Assured for API testing, adding Allure is a small setup investment for significantly better visibility into test results.
Related Links
Discover more from Rotebit
Subscribe to get the latest posts sent to your email.
