- Notifications
You must be signed in to change notification settings - Fork1
A Java-based API testing automation framework built with RestAssured and TestNG. It streamlines REST API testing by supporting full CRUD operations, API key/token authentication, and flexible assertions. Utilizes Jackson for JSON handling and DataFaker for realistic data generation, making it ideal for scalable and maintainable test suites.
License
cihat-kose/restassured-api-learning-path
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- Project Overview
- Features
- Installation
- Configuration
- Usage
- Folder Structure
- Dependencies
- Reporting and Logs
- Contributing
- License
Therestassured-api-learning-path is a Java-based API testing framework designed to automate REST API validations usingRestAssured,TestNG, andHamcrest. It supports comprehensive CRUD operations across multiple public APIs and includes structured logging, assertions, and POJO-based deserialization withJackson. The framework leveragesDataFaker to generate dynamic and localized test data, enhancing variability in test scenarios.
This framework includes test scenarios against the following public/mock APIs:
Zippopotam.us API
Provides postal code and location data for validating JSON structure and values.
🔗http://api.zippopotam.usGoRest API
User and comment management with full CRUD support.
🔗https://gorest.co.in/public/v2Campus API (Mersys)
Simulates country/location management with role-based authentication.
🔗https://test.mersys.ioRestful-Booker API
Designed to simulate hotel booking flows with authentication and full lifecycle actions (POST,PUT,PATCH,DELETE).
🔗https://restful-booker.herokuapp.comReqres API
Allows testing of pagination, user creation, and BDD validations.
🔗https://reqres.in/api
For detailed test implementations, seeKey Test Scenarios.
API Testing with RestAssured
Supports HTTP methods includingGET,POST,PUT,PATCH, andDELETEfor comprehensive API coverage.POJO Modeling
Enables object-oriented validation by deserializing JSON responses into clean, reusable Java POJO classes.Behavior-Driven Development (BDD)
Uses TestNG annotations and fluent RestAssured syntax to define test flows clearly and readably.Data Randomization with DataFaker
Integratesnet.datafakerto generate realistic and localized test data dynamically.Reusable Specifications
UtilizesRequestSpecificationandResponseSpecificationto centralize request/response configurations.Token-Based Authentication
Handles authentication dynamically using tokens (e.g., for secured booking APIs).API Key Authentication
Supports header-based API key testing (e.g., for role-restricted endpoints like Campus API).Comprehensive Logging
Automatically logs URIs, request/response bodies, headers, and status codes to simplify debugging.Dependency Management with Maven
Ensures reliable builds and version control through Maven with clearly defined dependencies.Multi-API Integration
Implements test flows across five different public APIs to validate CRUD operations, auth flows, and data handling.
Clone the Repository:
git clone https://github.com/cihat-kose/restassured-api-learning-path.git
Import the Project in IntelliJ IDEA:
- Open IntelliJ IDEA.
- SelectFile > Open and choose the project folder.
- Ensure Maven auto-import is enabled to download dependencies.
Install Plugins (if required):
- TestNG andRestAssured support plugins in IntelliJ IDEA for enhanced IDE integration.
- TestNG.xml: Defines the suite structure and test class execution flow.
- pom.xml: Manages dependencies and configurations for the framework.
To run tests, use Maven or execute directly from IntelliJ IDEA.
mvn cleantest- Right-click on
TestNG.xmland selectRun to execute all tests. - Alternatively, right-click any test class or method to run specific tests.
_01_APITestIntro.java
Intro to basicGETrequests, response logging, JSON field validation, and assertions with Hamcrest._02_APITestSpec.java
Demonstrates usage of reusable specifications withRequestSpecBuilderandResponseSpecBuilder._03_APITestExtract.java
Focuses on extracting response data using.path()and validating with TestNG assertions._04_APITestPOJO.java
Shows how to deserialize JSON responses into custom POJO classes likeLocationandPlace._05_Tasks.java
Collection of exercise-style test cases usingjsonplaceholder.typicode.comwith validation and POJO handling._06_PathAndJSONPath.java
Explains and contrasts usage of.path()vs.jsonPath()in extracting nested JSON data and converting to Java objects._07_GoRestUsersTest.java
Handles user creation, retrieval by ID, updating, and deletion using GoRest API._08_GoRestCommentTest.java
Manages comments: creation, retrieval, update, and deletion._09_CountryTest.java
Covers country creation, duplicate checks, updates, and deletions in the Campus API._10_RestfulBookerAPITest.java
Tests hotel booking flows: token generation, booking creation, update (PUT & PATCH), retrieval, and deletion._11_ReqresUserTest.java
Includes status code checks, BDD-style tests, and user creation with POST._12_APIKeyTest.java
Demonstrates sending authenticated requests using API keys.
This project commonly encounters a variety of HTTP status codes in responses. Below is a summary of some frequently used status codes and their meanings:
cihat-kose/restassured-api-learning-path/│├── src/│ └── test/│ ├── java/│ │ ├── model/ # POJO models for JSON response data│ │ │ ├── Country.java│ │ │ ├── Location.java│ │ │ ├── Place.java│ │ │ ├── ToDo.java│ │ │ └── User.java│ │ ├── _01_APITestIntro.java # Intro to basic API tests and assertions│ │ ├── _02_APITestSpec.java # Reusable request/response specifications│ │ ├── _03_APITestExtract.java # Extracting and asserting response data│ │ ├── _04_APITestPOJO.java # Deserialization into POJOs│ │ ├── _05_Tasks.java # Task-style practical API test cases│ │ ├── _06_PathAndJSONPath.java # Path vs JSONPath comparison│ │ ├── _07_GoRestUsersTest.java # GoRest: user CRUD│ │ ├── _08_GoRestCommentTest.java # GoRest: comment CRUD│ │ ├── _09_CountryTest.java # Campus API: country CRUD│ │ ├── _10_RestfulBookerAPITest.java# Restful-Booker: full booking flow│ │ ├── _11_ReqresUserTest.java # ReqRes: status & BDD testing│ │ └── _12_APIKeyTest.java # API Key authentication testing│ ││├── TestNG.xml # TestNG suite configuration│├── target/ # Build output (generated)├── images/ # Project images│ └── HTTP_Status_Codes.png # HTTP status codes reference image├── pom.xml # Maven build configuration└── README.md # Project overview and structure
⚠️ This project uses Java 21 features (e.g., text blocks, modern APIs). Ensure your JDK version is 21 or above.
Dependencies are managed inpom.xml. Key dependencies include:
- RestAssured: For making HTTP requests to test APIs.
- TestNG: For organizing and managing test execution.
- Hamcrest: For enhanced assertions in test validations.
- Jackson: For JSON serialization and deserialization.
- DataFaker: For generating realistic and localized fake test data.
- SLF4J (Simple Logging Facade for Java): For logging support.
This framework logs API requests and responses, which can be useful for debugging. Logs include:
- Request and Response Bodies: Automatically logged for all test methods.
- Status Codes and Headers: Available in logs to confirm correct responses.
Test results and logs are saved in thetarget directory after test execution.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
This project is licensed under the MIT License - see theLICENSE file for details.
About
A Java-based API testing automation framework built with RestAssured and TestNG. It streamlines REST API testing by supporting full CRUD operations, API key/token authentication, and flexible assertions. Utilizes Jackson for JSON handling and DataFaker for realistic data generation, making it ideal for scalable and maintainable test suites.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
