This project was created to start the initial steps with test automation for a REST API using Rest-Assured. It tests the API: petstore
- Java JDK 8
- Maven installed and in your classpath
You can open each test class on src\test\java
and execute all of them, but I recommend you run it by the
command line. It enables us to run in different test execution strategies and, also in a pipeline, that is the repo
purpose.
The test suites can be run directly by your IDE or by command line.
If you run mvn test
all the tests will execute because it's the regular Maven lifecycle to run all the tests.
To run different suites based on the groups defined for each test you must inform the property -Dgroups
and the group
names.
The example below shows how to run the test for each pipeline stage:
pipeline stage | command |
---|---|
users tests | mvn test -Dgroups="users" |
pet tests | mvn test -Dgroups="pets" |
all tests | mvn test |
This project uses Allure Report to automatically generate the test report. There are some configuration to make it happen:
- aspectj configuration on
pom.xml
file allure.properties
file onsrc/test/resources
You can use the command line to generate it in two ways:
mvn allure:serve -Dallure.results.directory=../allure-results
: will open the HTML report into the browsermvn allure:report -Dallure.results.directory=../allure-results
: will generate the HTML port attarget/site/allure-maven-plugin
folder
APIConfig is singleton class for test configurations
ResponseCode to make response code more readable
ConfigReader is to read environment files like qa,stage,prod
Wrapper class to find data from mysql database
Wrapper class to read data from excelsheet
Wrapper to read/update environment properties as key/values used in APIConfig
config files for log4j and allure
Contains builder classes for pet
and user
model
Wrapper class for rest calls for pet
and user
BaseTest that sets the initial aspects to make the requests using RestAssured.
PetTests contains unit test for /pet
UserTest contains unit test for /user
It contains test properties file
Wrapper class for rest-assured class which asserts the response with each call.
- RestAssured library to test REST APIs
- Testng to support the test creation
- jxl to read excel sheets for data
- Log4J2 as the logging strategy
- Allure Report as the testing report strategy
- Singleton
- Data Provider
- Builder
- Request and Response Specification
- BaseTest