A comprehensive framework for API testing built with REST Assured, Cucumber, and TestNG.
📖 Live Documentation: https://aditi66.github.io/api-automation-framework/
The documentation is automatically deployed to GitHub Pages and includes:
# Clone the repository
git clone https://github.com/Aditi66/api-automation-framework.git
cd api-automation-framework
# Build the project
mvn clean install
# Run tests
mvn test
The API Automation Framework is built with modern Java technologies and follows industry best practices:
api-automation-framework/
├── src/
│ ├── main/
│ │ ├── java/org/aditi/api_automation/
│ │ │ ├── annotations/ # Custom annotations
│ │ │ ├── api/ # API domain classes
│ │ │ ├── config/ # Configuration management
│ │ │ ├── dto/ # Data transfer objects
│ │ │ ├── handlers/ # Dynamic proxy handlers
│ │ │ ├── requests/ # Request factories
│ │ │ ├── specs/ # REST Assured specifications
│ │ │ └── utils/ # Utility classes
│ │ └── resources/
│ │ ├── environment/ # Environment-specific configs
│ │ ├── requests/ # JSON request templates
│ │ └── response/schemas/ # JSON schema files
│ └── test/
│ ├── java/org/aditi/api_automation/
│ │ ├── asserts/ # Validation classes
│ │ ├── runner/ # Test runners
│ │ └── steps/ # Cucumber step definitions
│ └── resources/
│ └── features/ # Cucumber feature files
├── docs/ # Documentation
├── pom.xml # Maven configuration
└── README.md # Project overview
The framework uses dynamic proxies and annotations for configuration management:
// Access configuration
String baseUrl = AppConfig.getConfig().getBaseUrl();
// Add new properties
@ConfigProperty("NEW_PROPERTY")
String getNewProperty();
Follow the Arrange-Act-Assert pattern:
@Given("I have valid user credentials")
public void i_have_valid_user_credentials() {
// Arrange: Setup test data
loginRequest = new UserLoginRequest("testuser", "testpass");
}
@When("I attempt to login")
public void i_attempt_to_login() {
// Act: Perform the action
response = UserApi.login(loginRequest);
}
@Then("I should receive a successful response")
public void i_should_receive_a_successful_response() {
// Assert: Validate the result
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200);
}
Use JSON templates for request specifications:
@RequestTemplateFile("requests/login.json")
RequestSpecBuilder loginRequest(String username, String password);
Use fluent validation methods:
ValidateGenericResponse.assertThat(response)
.httpStatusCodeIs(200)
.matchesSchema("response/schemas/user-schema.json")
.validateJsonPathData("data.id", 1)
.containsValue("success");
Comprehensive documentation is available in the docs/
directory:
src/main/java/org/aditi/api_automation/api/
src/test/resources/features/
src/test/java/org/aditi/api_automation/steps/
src/main/resources/requests/
src/main/resources/response/schemas/
ConfigFactory
interface with @ConfigProperty
annotationAppConfig.getConfig().getPropertyName()
in your codesrc/main/resources/requests/
RequestFactory
with @RequestTemplateFile
annotationAppRequests.getRequestFactory()
Contributions are welcome! Please see our Contributing Guide for details.
We welcome contributions to improve the documentation! Please see our Documentation Contributing Guide for details.
This project is licensed under the MIT License.
Happy Testing! 🚀
For detailed information, start with the Documentation Index to find what you need.