visit
In this article, I want to tell you how to connect and further generate Allure
reports for a test project if your test project is made on the Citrus Framework. I hope you know about Allure framework, which is designed to generate reports after passing tests. The report opens on a browser page, where you can see which tests passed successfully and which did not, you can also see at which test step the expected result did not match.
1. First of all, the Allure distribution must be installed locally and the path to the distribution must be written in PATH, similar to installing Maven. The
distribution can be taken from here by choosing the latest version:
//repo.maven.apache.org/maven2/io/qameta /allure/allure-commandline
allure --version
<properties>
<aspectj.version>1.9.4</aspectj.version>
<allure.version>2.22.0</allure.version>
</properties>
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<failIfNoTests>false</failIfNoTests>
<workingDirectory>${project.build.directory}</workingDirectory>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<systemPropertyVariables>
<allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
</systemPropertyVariables>
</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>2.10.0</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<allureDownloadUrl>//repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
</configuration>
</plugin>
</plugins>
</build>
@Story("GET REQUEST")
public class FirstTestGetUser extends TestNGCitrusSupport {
private TestContext context;
@Test(description = "Getting information about user")
@CitrusTest
public void getTestActions() {
this.context = citrus.getCitrusContext().createTestContext();
// "Send GET request"
sendRequest();
// "Get response"
getResponse();
}
@Step("Send GET request")
public void sendRequest() {
$(http()
.client("restClientReqres")
.send()
.get("users/" + context.getVariable("userId")));
}
@Step("Get response")
public void getResponse() {
$(http().client("restClientReqres")
.receive()
.response(HttpStatus.OK)
.message()
.type(MessageType.JSON)
.body(new ObjectMappingPayloadBuilder(getJsonData(), "objectMapper"))
);
}
public User getJsonData() {
User user = new User();
Data data = new Data();
data.setId(Integer.valueOf(context.getVariable("userId")));
data.setEmail("[email protected]");
data.setFirstName("Janete");
data.setLastName("Weaver");
data.setAvatar("//reqres.in/img/faces/2-image.jpg");
user.setData(data);
Support support = new Support();
support.setUrl("//reqres.in/#support-heading");
support.setText("To keep ReqRes free, contributions towards server costs are appreciated!");
user.setSupport(support);
return user;
}
}