Integrate Rest Assured and Allure


Integrate Rest Assured and Allure

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.

1
.filter(new AllureRestAssured())

First add maven dependeny in your pom.xml file.

1
2
3
4
5
6
<!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-rest-assured -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-rest-assured</artifactId>
<version>2.13.0</version>
</dependency>

Simple example for how to use

1
2
3
4
5
6
7
8
9
@Test
public void planetsCheck() {
Response response = given()
.filter(new AllureRestAssured())
.when()
.get("https://swapi.co/api/").then()
.extract().response();
Assert.assertEquals(response.statusCode(), 200);
}

Second way is with RequestSpecBuilder

1
2
3
4
5
6
spec = new RequestSpecBuilder()
.setContentType(ContentType.JSON)
...
.addFilter(new AllureRestAssured())
...
.build();

To create our report first run these command after test run.

1
mvn clean test allure:report

Our test report should be located in allure-report folder and should look like below.