TL;DR
Here's a straightforward tutorial on running automated API tests using JAVA and RESTASSURED.
Here's a straightforward tutorial on running automated API tests using JAVA and RESTASSURED.
There are many types of queries that applications communicate with each other. The most important, however, are 4 so-called CRUD queries (create, read, update, delete).
The following types of requests suit them:
In order to construct a valid Api request of the tested application, we need to know it:
First, we need to create a new Maven project in IntelliJ IDEA.
Adding the dependency to the pom.xml file - these are the entries which plugins are to be “installed” to our project. In our case, we need RestAssured, TestNG and AssertJ:
Adding a Java Class file named e.g. MockoonTest to the ...src/test/java directory in the project structure:
In the body of the newly added class, we create a variable of type String and assign it the value base url:
Copying the code for the first test:
Before starting the test, run the endpoint simulation, in our case with the prefix "/ testdominik".
Launch the previously installed Mockoon app and proceed as below:
Click the green play triangle to the left of the test function and select "Run":
Successful test result:
Explore our collection of insightful blog posts.