Skip to content

Mcube333/java-qa-automation-framework

Repository files navigation

πŸš€ Java QA Automation Framework (Web + API)

Build Status License Java TestNG

πŸ“Œ Overview

This repository contains a production-ready, scalable QA automation framework built using Java, Selenium, Rest Assured, TestNG, Maven, and GitHub Actions.
Designed to follow enterprise automation standards, this framework is suitable for:

  • Real-world production testing 🌐
  • CI/CD pipelines πŸ€–
  • Technical interviews and portfolio demonstrations 🎯

✨ Key Capabilities

  • 🌐 Web UI automation (Selenium WebDriver)
  • πŸ”— API automation (Rest Assured)
  • ⚑ Parallel execution & thread-safe driver management
  • 🌍 Cross-browser testing (Chrome, Firefox, Edge)
  • πŸ§ͺ Smoke, sanity, and regression testing classification
  • πŸ” Retry logic for flaky tests (RetryAnalyzer)
  • πŸ“Š Rich Extent Reports (web steps, API logs)
  • πŸ€– CI/CD execution via GitHub Actions with matrix runs

πŸ›  Tech Stack

Layer Technology
Language Java 17
UI Automation Selenium WebDriver
API Automation Rest Assured
Test Framework TestNG
Build Tool Maven
Driver Management WebDriverManager
Reporting Extent Reports
Logging Log4j
CI/CD GitHub Actions

πŸ“ Project Structure

java-adapter
β”‚
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ main
β”‚   β”‚   └── java
β”‚   β”‚       └── framework
β”‚   β”‚           β”œβ”€β”€ config
β”‚   β”‚           β”‚   β”œβ”€β”€ ConfigManager.java
β”‚   β”‚           β”‚   └── ApiConfig.java
β”‚   β”‚           β”‚
β”‚   β”‚           β”œβ”€β”€ driver
β”‚   β”‚           β”‚   β”œβ”€β”€ DriverFactory.java
β”‚   β”‚           β”‚   β”œβ”€β”€ DriverManager.java
β”‚   β”‚           β”‚   └── BrowserType.java
β”‚   β”‚           β”‚
β”‚   β”‚           β”œβ”€β”€ listeners
β”‚   β”‚           β”‚   └── ExtentTestListener.java
β”‚   β”‚           β”‚
β”‚   β”‚           β”œβ”€β”€ retry
β”‚   β”‚           β”‚   β”œβ”€β”€ RetryAnalyzer.java
β”‚   β”‚           β”‚   └── RetryAnnotationTransformer.java
β”‚   β”‚           β”‚
β”‚   β”‚           └── utils
β”‚   β”‚               β”œβ”€β”€ ExtentManager.java
β”‚   β”‚               └── CommonUtils.java
β”‚   β”‚
β”‚   β”œβ”€β”€ test
β”‚   β”‚   └── java
β”‚   β”‚       └── tests
β”‚   β”‚           β”œβ”€β”€ base
β”‚   οΏ½οΏ½           β”‚   β”œβ”€β”€ BaseTest.java
β”‚   β”‚           β”‚   β”œβ”€β”€ BaseWebTest.java
β”‚   β”‚           β”‚   └── BaseApiTest.java
β”‚   β”‚           β”‚
β”‚   β”‚           β”œβ”€β”€ web
β”‚   β”‚           β”‚   └── (Web test classes)
β”‚   β”‚           β”‚
β”‚   β”‚           └── api
β”‚   β”‚               └── (API test classes)
β”‚   β”‚
β”‚   └── resources
β”‚       └── config
β”‚           └── env.properties
β”‚
β”œβ”€β”€ testng.xml
β”œβ”€β”€ pom.xml
└── .github/workflows/ci.yml

πŸ”§ Configuration Management

All environment-specific and runtime configuration is centralized in src/test/resources/config/env.properties, with override priority as follows:

  1. Maven system properties (e.g. -Dbrowser=chrome, -Denv=qa)
  2. TestNG parameters (when used)
  3. env.properties defaults

Example env.properties keys:

browser=chrome
baseUrl=https://example.com
apiBaseUrl=https://api.example.com
timeout.ms=5000
retry.count=2

πŸš— WebDriver Architecture

  • Thread-safe WebDriver management using ThreadLocal ensures fully isolated execution for parallel runs.
  • Browser lifecycle:
    • Initialized in @BeforeMethod
    • Quit and cleaned in @AfterMethod
  • Supported browsers: Chrome, Firefox, Edge (via WebDriverManager)

🌐 API Automation Design

  • Built using Rest Assured for API interactions.
  • API tests do NOT open browsers.
  • Base URI initialized once per test class; requests & responses logged and attached to Extent reports.

πŸ§ͺ Test Classification (TestNG Groups)

Use TestNG groups to categorize tests:

  • smoke β€” Critical flow validation 🚨
  • sanity β€” Basic stability checks βœ…
  • regression β€” Full test coverage 🧭
  • api β€” API-only execution πŸ”—
  • web β€” Web-only execution 🌐

Sample:

@Test(groups = {"smoke", "regression"})
public void criticalFlowTest() { ... }

πŸ” Retry Logic

  • Implemented using RetryAnalyzer and integrated via a TestNG annotation transformer.
  • Automatically retries failed tests to mitigate flaky failures. Configure retry count in env.properties or via system property.

πŸ“Š Reporting

  • Extent Reports are generated after every execution and include:
    • Web test steps and screenshots (if enabled)
    • API request and response logs
    • Test status and failure details

Output directory:

test-output/

▢️ Running Tests Locally

Run all tests:

mvn clean test

Run tests by groups:

# Smoke
mvn clean test -Dgroups=smoke

# Regression
mvn clean test -Dgroups=regression

Run API-only or Web-only via Maven profiles and browser override:

# API tests only
mvn clean test -Papi

# Web tests only (explicit browser)
mvn clean test -Pweb -Dbrowser=chrome

Parallel execution is controlled by testng.xml and TestNG parameters (method-level or test-level parallelism). Thread-safe driver management prevents conflicts during parallel runs.


πŸ€– CI/CD β€” GitHub Actions

CI features:

  • Matrix execution (browsers: Chrome, Firefox; environments: dev, qa)
  • Automatic browser setup using WebDriverManager or containerized drivers
  • Test report artifacts uploaded after execution
  • Triggers:
    • push to main
    • pull request against main

A sample workflow file: .github/workflows/ci.yml (ensure it matches your desired matrix and artifact upload steps).


βœ… Current Capabilities Summary

  • βœ” Web + API automation
  • βœ” Cross-browser testing
  • βœ” Parallel execution
  • βœ” Environment-specific execution
  • βœ” Retry mechanism for flaky tests
  • βœ” Extent reporting with API logs
  • βœ” CI/CD ready (GitHub Actions)
  • βœ” Interview-ready architecture & examples

πŸš€ Future Enhancements (Optional)

  • Headless execution toggle for faster CI runs
  • Screenshot capture on failure (per-test)
  • API schema validation (JSON Schema / OpenAPI checks)
  • Dockerized execution for reproducible CI environments
  • Add Allure reporting and centralized test data management

πŸ“‚ Examples & Recommendations

Add example folders to accelerate onboarding:

  • examples/basic β€” simple web + api usage examples
  • examples/async β€” async flows and advanced scenarios
  • examples/spring-boot β€” Spring Boot test integration (if relevant)

🀝 Contributing

We welcome contributions! Suggested flow:

  1. Fork the repo 🍴
  2. Create a branch: git checkout -b feat/my-feature 🌱
  3. Add tests and documentation βœ…
  4. Run all tests locally and ensure code style is followed πŸ”
  5. Open a pull request with a clear description and link to any related issue πŸ”—

Please include unit tests for new logic and update README/examples when APIs change.


πŸ›‘οΈ License

This project is licensed under the MIT License β€” see the LICENSE file for details. πŸ“


πŸ‘¨β€πŸ’» Author Notes

This framework is designed with scalability, maintainability, and real-world usage in mind. It reflects industry best practices for modern QA automation and is suitable for CI pipelines and interview/portfolio demos.

Maintainer: @Mcube333
Issues & feature requests: please open GitHub issues

About

Enterprise-grade Java QA Automation Framework for Web & API testing using Selenium, REST Assured, TestNG, Maven, and GitHub Actions with CI/CD, parallel execution, and cross-browser support.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors