In modern software development, API testing is critical to ensure backend services work correctly, reliably, and securely. Automated API testing helps teams validate endpoints quickly and integrate testing into CI/CD pipelines.
To demonstrate a practical approach, I built an API Automation Framework using Java and BDD principles.
This repository provides a clean and scalable structure to automate REST APIs efficiently.
๐ Why API Automation?
Manual API testing with tools like Postman is useful for quick checks, but it becomes difficult to maintain when the number of test cases grows. A proper automation framework provides:
โ
Faster regression testing
โ
Reusable test components
โ
CI/CD integration
โ
Detailed reporting
โ
Scalable architecture
Automation frameworks built with Java + REST Assured + BDD are widely used in enterprise QA environments.
๐ Tech Stack Used
This framework uses modern automation tools commonly used by SDET engineers:
Java
REST Assured
Cucumber BDD
Maven
TestNG / JUnit
JSON Schema Validation
Git & GitHub
๐ Project Structure
`
apiAutoFramework
โ
โโโ src
โ โโโ main
โ โ โโโ java
โ โ โโโ resources
โ โ
โ โโโ test
โ โโโ java
โ โโโ com.electrolab.api
โ โ
โ โโโ base
โ โ โโโ ScenarioContext.java
โ โ โโโ TestContext.java
โ โ
โ โโโ config
โ โ โโโ ConfigManager.java
โ โ โโโ Environment.java
โ โ
โ โโโ hooks
โ โ โโโ Hooks.java
โ โ
โ โโโ managers
โ โ โโโ ApiManager.java
โ โ โโโ TokenManager.java
โ โ
โ โโโ mock
โ โ โโโ MockServer.java
โ โ โโโ UserMock.java
โ โ
โ โโโ models
โ โ โโโ AuthResponse.java
โ โ โโโ User.java
โ โ
โ โโโ runners
โ โ โโโ TestRunners.java
โ โ
โ โโโ specbuilder
โ โ โโโ SpecBuilder.java
โ โ
โ โโโ stepdefinitions
โ โ โโโ UserSteps.java
โ โ
โ โโโ utils
โ โโโ ApiClient.java
โ โโโ JsonUtils.java
โ โโโ LoggerUtils.java
โ โโโ RetryAnalyzer.java
โ
โโโ resources
โโโ features
โโโ user.feature
โ๏ธ Framework Features
โ BDD testing using Cucumber
โ API testing using RestAssured
โ Reusable RequestSpecBuilder
โ Token-based authentication handling
โ Environment configuration support
โ Modular and maintainable architecture
โ Logging and retry mechanisms
โ JSON utilities for request/response handling
๐งช Sample BDD Scenario
Feature: User API
Scenario: Get users list
Given User calls GET users API
Then response status should be 200
๐งฑ Request Specification Builder
Reusable request configuration using SpecBuilder.
public class SpecBuilder {
public static RequestSpecification getRequest() {
return new RequestSpecBuilder()
.setBaseUri(ConfigManager.get("qa.url"))
.addHeader("Content-Type", "application/json")
.build();
}
}
๐ Token Manager
Handles authentication tokens dynamically and injects them into API requests.
๐ง Running Tests
Run using Maven
Run from IDE
Run the TestRunners.java file.
๐ Future Enhancements
Parallel execution
Allure reports
CI/CD integration (Jenkins / GitHub Actions)
Dockerized test execution
API contract testing
Performance testing integration`
Top comments (0)