<<<<<<< HEAD
This project contains automated tests for the ReqRes API using Java, Rest Assured, and TestNG.
API Test Automation/
├── src/
│ ├── main/java/com/apitest/
│ │ └── utils/
│ │ ├── APIConfig.java (API configuration and constants)
│ │ └── APIClient.java (HTTP client wrapper)
│ └── test/java/com/apitest/
│ ├── tests/
│ │ └── UserAPITest.java (Test cases)
│ └── models/
│ ├── User.java (User model)
│ └── UserResponse.java (Response wrapper)
├── pom.xml (Maven configuration)
├── testng.xml (TestNG suite configuration)
└── README.md (This file)
- Java 11 or higher
- Maven 3.6+
- Internet connection (to access https://reqres.in/)
- Endpoint:
POST /api/users - Validates:
- HTTP Status Code = 201 (Created)
- User ID is generated and stored
- Response contains created user details (name, job, timestamp)
- Endpoint:
GET /api/users/{userId} - Validates:
- HTTP Status Code = 200 (OK)
- Retrieved user details match created user
- User ID, name, and job are correct
- Endpoint:
PUT /api/users/{userId} - Validates:
- HTTP Status Code = 200 (OK)
- User name is updated correctly
- User job is updated correctly
- User ID remains unchanged
- Updated timestamp is present
mvn testmvn test -Dtest=UserAPITestmvn test -Xmvn surefire:test============ Test 1: Create User ============
Response Status: 201
Response Body: {"name":"Automation Tester","job":"QA Engineer","id":123,"createdAt":"2026-05-20T10:30:00.000Z"}
✓ User created successfully with ID: 123
✓ Status Code validation: PASSED
============ Test 2: Get User Details ============
Response Status: 200
✓ User details retrieved successfully
✓ User ID validation: PASSED
✓ User name validation: PASSED
✓ User job validation: PASSED
============ Test 3: Update User Details ============
Response Status: 200
✓ User updated successfully
✓ Name updated from 'Automation Tester' to 'Updated Automation Tester'
✓ Job updated from 'QA Engineer' to 'Senior QA Engineer'
✓ All validations: PASSED
- Rest Assured 5.3.2: RESTful API testing library
- TestNG 7.8.1: Testing framework
- Gson 2.10.1: JSON serialization/deserialization
- Lombok 1.18.30: Reduces boilerplate code
API endpoints and constants can be modified in APIConfig.java:
public static final String BASE_URL = "https://reqres.in";
public static final String DEFAULT_USER_NAME = "Automation Tester";
public static final String DEFAULT_USER_JOB = "QA Engineer";┌─────────────────────────────────────┐
│ Test 1: Create User │
│ ✓ POST /api/users │
│ ✓ Validate Status 201 │
│ ✓ Store User ID │
└──────────────┬──────────────────────┘
│ (Pass)
┌──────────────▼──────────────────────┐
│ Test 2: Get User Details │
│ ✓ GET /api/users/{userId} │
│ ✓ Validate Status 200 │
│ ✓ Verify User Data │
└──────────────┬──────────────────────┘
│ (Pass)
┌──────────────▼──────────────────────┐
│ Test 3: Update User │
│ ✓ PUT /api/users/{userId} │
│ ✓ Validate Status 200 │
│ ✓ Verify Updated Data │
└─────────────────────────────────────┘
assertEquals(): Validate exact values (status codes, strings)assertNotNull(): Verify response fields are populatedassertTrue()/assertFalse(): Validate boolean conditions
- Tests are dependent on each other using
dependsOnMethodsin TestNG - User ID from Test 1 is used in Tests 2 and 3
- Each test prints detailed output for debugging purposes
- Assertions provide clear failure messages with expected vs actual values
mvn clean installmvn dependency:tree- Check internet connection
- Verify https://reqres.in/ is accessible
- Check logs for detailed error messages
Extend this framework by adding:
- Configuration file support (.properties, .yaml)
- Parameterized tests with data providers
- Additional endpoints (List users, Delete user, etc.)
- Custom assertions and utilities
- Test reporting (Allure, ExtentReports)
- CI/CD integration (Jenkins, GitHub Actions)
b419ba1 (Initial commit: API Test Automation upgrade + product tests)