Enterprise-grade REST API automation framework built with REST Assured, TestNG, and Maven. Designed for comprehensive API testing with request/response validation, JSON schema validation, and detailed reporting.
- β REST Assured - Powerful API testing library
- β TestNG Framework - Test management and parallel execution
- β Maven Build - Dependency management
- β Request/Response Validation - Comprehensive assertions
- β JSON Schema Validation - Contract testing
- β Environment Management - Multi-environment support
- β Logging - Log4j integration
- β HTML Reports - Detailed test execution reports
- β Data-Driven Testing - Parameterized test support
- Java 11 or higher
- Maven 3.6+
- IDE (Eclipse, IntelliJ IDEA, or VS Code)
# Clone the repository
git clone https://github.com/snnarangsumit/RestAssuredFramework.git
cd RestAssuredFramework
# Install dependencies
mvn clean install
# Run tests
mvn testRestAssuredFramework/
β
βββ src/
β βββ main/java/
β β βββ api/ # API endpoint classes
β β βββ utils/ # Utility classes
β β βββ models/ # POJO classes for request/response
β β
β βββ test/java/
β βββ tests/ # Test classes
β
βββ reports/ # Test reports (auto-generated)
βββ test-output/ # TestNG output (auto-generated)
β
βββ pom.xml # Maven configuration
βββ log4j.xml # Logging configuration
βββ README.md # Documentation
<dependencies>
<!-- REST Assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.3.0</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.0</version>
</dependency>
<!-- JSON Schema Validator -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>mvn clean testmvn test -Dtest=LoginAPITestmvn test -DsuiteXmlFile=testng.xmlmvn clean test
# Reports available in: reports/ and test-output/import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
public class APITest {
@Test
public void testGetUser() {
given()
.baseUri("https://reqres.in/api")
.header("Content-Type", "application/json")
.when()
.get("/users/2")
.then()
.statusCode(200)
.body("data.id", equalTo(2))
.body("data.email", notNullValue())
.log().all();
}
@Test
public void testCreateUser() {
String requestBody = "{"
+ "\"name\": \"John Doe\","
+ "\"job\": \"QA Engineer\""
+ "}";
given()
.baseUri("https://reqres.in/api")
.header("Content-Type", "application/json")
.body(requestBody)
.when()
.post("/users")
.then()
.statusCode(201)
.body("name", equalTo("John Doe"))
.body("job", equalTo("QA Engineer"))
.body("id", notNullValue());
}
}- β GET requests - Retrieve data
- β POST requests - Create resources
- β PUT/PATCH requests - Update resources
- β DELETE requests - Remove resources
- β Authentication testing
- β Header validation
- β Status code verification
- β Response body validation
- β JSON schema validation
- β Error handling
- Located in
test-output/folder - Open
index.htmlin browser - Detailed test execution results
- Pass/Fail statistics
- Execution time
- Located in
reports/folder - HTML format with detailed logs
- Request/Response data
- Screenshots (if applicable)
- Separation of Concerns - API endpoints, tests, and utilities separated
- Reusable Components - Common methods in utility classes
- Data-Driven Testing - External data sources support
- Logging - Comprehensive request/response logging
- Assertions - Clear and meaningful validations
- Error Handling - Proper exception management
- Configuration Management - Environment-specific settings
- Java - Programming language
- REST Assured - API testing library
- TestNG - Testing framework
- Maven - Build automation
- Log4j - Logging framework
- JSON Schema Validator - Contract validation
- REST API testing fundamentals
- HTTP methods (GET, POST, PUT, DELETE)
- Request/Response validation
- JSON parsing and validation
- Authentication mechanisms
- Header management
- Query parameters
- Path parameters
- Request body handling
- Response extraction
- Create test class in
src/test/java/tests/ - Extend base test class (if available)
- Use REST Assured DSL for API calls
- Add assertions using TestNG or Hamcrest matchers
- Run with Maven:
mvn test -Dtest=YourTestClass
Sumit Narang
- LinkedIn: linkedin.com/in/sumit-narang15
- GitHub: @snnarangsumit
This project is available for reference and learning purposes.
β If you find this framework helpful, please give it a star!