Rest Assured API Test Framework
This project is a Java-based API testing framework using Rest Assured, TestNG, and Allure for reporting. It is designed for easy, maintainable, and robust API automation against RESTful endpoints.
Features
- Modular helper classes for API requests
- Centralized configuration for base URL and headers
- Data-driven testing support (JSON)
- CRUD test examples for Reqres API
- Allure reporting integration
Project Structure
rest-assured-api-tests/
├── pom.xml # Maven project file with dependencies and plugins
├── src/
│ ├── main/
│ │ └── java/com/api/
│ │ ├── config/ # API config (base URL, headers)
│ │ └── helpers/ # API helper methods (GET, POST, etc.)
│ └── test/
│ ├── java/com/api/tests/ # TestNG test classes
│ └── resources/data/ # Test data (e.g., users.json)
└── target/
└── allure-results/ # Allure results (after test run)
Prerequisites
- Java 8 or higher
- Maven 3.6+
How to Run
-
Install dependencies and run tests:
mvn clean test -
Generate Allure report:
mvn allure:report -
View Allure report in browser:
mvn allure:serveThis will open the Allure dashboard locally.
-
To see results
python3 -m http.server 9999 --directory target/
Configuration
- Base URL and headers are set in
src/main/java/com/api/config/ApiConfig.java. - Test data (e.g., users) is in
src/test/resources/data/users.json.
Example Test
See UserApiTest.java for a full CRUD test using Rest Assured and Allure steps.
Customization
- Add new API helpers in
ApiHelper.java. - Add new test classes in
src/test/java/com/api/tests/. - Add or update test data in
src/test/resources/data/.
Allure Reporting
- Allure results are generated in
target/allure-results. - Reports include test steps, assertions, and metadata.
Troubleshooting
- If Allure results are not generated in
target/allure-results, ensure you are running tests with Maven and not from an IDE with a custom working directory. - Check
pom.xmlfor correct Surefire and Allure plugin configuration.
License
MIT