A robust and scalable API testing framework built with REST Assured, TestNG, and Java. This framework provides comprehensive testing capabilities for REST APIs with features like authentication, CRUD operations, logging, and test reporting.
- REST API Testing: Complete CRUD operations testing using REST Assured
- Authentication Support: Built-in login functionality with token management
- Data-Driven Testing: TestNG data providers for parameterized testing
- Comprehensive Logging: Log4j2 integration for detailed request/response logging
- Advanced Reporting: Extent Reports integration for beautiful HTML test reports
- Test Listeners: Custom test listeners for enhanced reporting and logging
- Request/Response Filtering: Custom filters for logging and debugging
- Fake Data Generation: Java Faker integration for realistic test data
- Configuration Management: Externalized configuration properties
- POJO Models: Clean separation of request/response models using Lombok
- Java 11 or higher
- Maven 3.6+
- IDE (IntelliJ IDEA, Eclipse, or VS Code)
- Java 11: Core programming language
- REST Assured 5.5.5: API testing library
- TestNG 7.11.0: Testing framework
- Log4j2 2.24.3: Logging framework
- Extent Reports 5.1.2: Advanced HTML test reporting
- Lombok 1.18.32: Reduces boilerplate code
- Jackson 2.19.2: JSON serialization/deserialization
- Java Faker 1.0.2: Test data generation
restassured-api-automation/
├── src/
│ ├── main/java/
│ │ ├── filters/
│ │ │ └── LoggingFilters.java # Request/Response logging filters
│ │ ├── listeners/
│ │ │ └── TestListeners.java # Test execution listeners
│ │ ├── models/
│ │ │ ├── request/
│ │ │ │ ├── LoginRequest.java # Login request POJO
│ │ │ │ └── ProductRequest.java # Product request POJO
│ │ │ └── response/
│ │ │ ├── LoginResponse.java # Login response POJO
│ │ │ └── ProductResponse.java # Product response POJO
│ │ ├── reporting/
│ │ │ └── ExtentReportManager.java # Extent Reports configuration
│ │ ├── services/
│ │ │ ├── base/
│ │ │ │ └── BaseService.java # Base service with common configuration
│ │ │ ├── AuthService.java # Authentication service
│ │ │ └── ProductService.java # Product CRUD operations
│ │ └── utils/
│ │ ├── CommonFunctions.java # Common utility functions
│ │ ├── ConfigReader.java # Configuration property reader
│ │ ├── LoginDataProvider.java # Test data provider for login
│ │ └── ProductRequestGenerator.java # Fake data generator
│ └── test/
│ ├── java/tests/
│ │ ├── EndToEndTest.java # End-to-end test scenarios
│ │ ├── LoginTest.java # Login test cases
│ │ └── Sample.java # Sample test class
│ └── resources/
│ ├── configuration/
│ │ └── config.properties # Configuration properties
│ └── log4j2.xml # Logging configuration
├── logs/
│ └── app.log # Application logs
├── reports/ # Extent Reports output directory
├── pom.xml # Maven dependencies
└── README.md # Readme file
-
Clone the repository:
git clone <repository-url> cd restassured-api-automation
-
Update configuration in
src/test/resources/configuration/config.properties:baseUrl=https://dummyjson.com username=your_username password=your_password
-
Install dependencies:
mvn clean install
Execution Demo: Watch the video on Vimeo
mvn testmvn test -Dtest=EndToEndTestmvn test -Dtest=EndToEndTest#testCreateProductmvn test -DsuiteXmlFile=testng.xml- Login with valid credentials
- Token verification
- Data-driven login testing
- Create Product: Generate fake product data and create new products
- Read Product: Retrieve product details by ID
- Update Product: Modify existing product information
- Delete Product: Remove products from the system
The framework includes a comprehensive end-to-end test that:
- Authenticates the user
- Creates a new product
- Reads the created product
- Updates the product details
- Deletes the product
The BaseService class provides common configuration for all API requests:
- Base URL configuration
- Request specification setup
- Logging filters integration
LoginDataProvider: Provides test data for login scenariosProductRequestGenerator: Generates realistic product data using Java Faker
- Log4j2 Configuration: Structured logging with different levels
- Request/Response Logging: Detailed logging of all API interactions
- Test Execution Logging: Comprehensive test execution tracking
- ExtentReportManager: Manages Extent Reports configuration and instance
- CommonFunctions: Utility functions for timestamp generation and configuration loading
- Test Listeners: Integrates with Extent Reports for automatic test reporting
Custom test listeners provide:
- Test execution start/finish notifications
- Success/failure logging
- Performance metrics
- Extent Reports integration for detailed test reporting
-
API Endpoints: The framework currently uses the DummyJSON API for testing. Update the
baseUrlin configuration for your target API. -
Authentication: The current implementation uses basic authentication. Modify
AuthServicefor different authentication methods (OAuth, JWT, etc.). -
Test Data: Product creation and updates use generated fake data. In production, you may want to use predefined test data.
-
Dependencies: Some tests have dependencies (e.g.,
testReadProductdepends ontestCreateProduct). This ensures proper test flow.
Test execution generates:
- Console output with detailed logs
- Log files in the
logs/directory - Extent Reports: Beautiful HTML reports with detailed test information
- Interactive dashboard with test statistics
- Detailed test execution logs with request/response data
- Timeline view of test execution
- System information and environment details
- Searchable test results
- TestNG HTML reports
Harichandra Chaudhari
- GitHub: @harichandra-github
- Linkedin: @harichandra-chaudhari
- Email: harichandrachaudhari21@gmail.com
- Phone: +91-866-900-9231
- REST Assured for excellent API testing capabilities
- TestNG for robust testing framework
- Extent Reports for beautiful HTML test reporting
- Java Faker for realistic test data generation
- DummyJSON for providing a test API
**Happy Testing! **