Skip to content

A data-driven API test automation framework built with RestAssured and integrated with Docker and Jenkins for reliable CI execution, reporting, and logging.

Notifications You must be signed in to change notification settings

earlbertmercado/restassured-petstore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

restassured_logo

Overview

A data-driven API test automation framework built with RestAssured and integrated with Docker and Jenkins for reliable CI execution, reporting, and logging.

Features

  • Robust API testing with built-in request and response validation
  • Modular, scalable framework with clear separation of concerns
  • Data-driven testing using external test data sources
  • Interactive HTML reporting and comprehensive Log4j2-based logging
  • JSON schema validation for contract-level API verification
  • Containerized test execution using Docker for environment consistency
  • CI-ready execution via Jenkins pipelines

Technologies Used

Language Java
Build Tool Maven
API Automation RestAssured
Testing Framework TestNG
Code Simplification Lombok
Logging Log4j2
Reporting ExtentReports
CI/CD Jenkins
Containerization Docker

Folder Structure

restassured-petstore/
├── assets/                         # Static assets
├── logs/                           # Generated Log4j2 log files from test executions
├── reports/                        # Test execution reports (ExtentReports output)
├── src/
│   ├── main/
│   │   ├── java/com/earlbertmercado/restassured/petstore/
│   │   │   ├── clients/            # API client classes responsible for sending HTTP requests
│   │   │   ├── config/             # Configuration loaders
│   │   │   ├── endpoints/          # Centralized API endpoint path definitions
│   │   │   ├── payloads/           # Request and response POJOs (Lombok-enabled models)
│   │   │   └── utils/              # Reusable utilities (data providers, validators, report manager)
│   │   └── resources/
│   │       ├── schemas/            # JSON schema files for response validation
│   │       ├── config.properties   # Environment and framework-level configuration
│   │       └── log4j2.xml          # Log4j2 logging configuration
│   └── test/
│       ├── java/com/earlbertmercado/restassured/petstore/
│       │   ├── base/               # Base test classes (common setup, teardown, specs)
│       │   └── tests/              # TestNG test classes grouped by API functionality
│       └── resources/
│           ├── testdata/           # External test data for data-driven testing
│           └── testng/             # TestNG suite XML files and execution configurations
├── Dockerfile                      # Docker image definition for test execution
├── Jenkinsfile                     # Jenkins pipeline definition for CI execution
└── pom.xml                         # Maven project configuration and dependency management

Prerequisites

  • Java 21 or higher
  • Maven 3.6+
  • Docker
  • IDE (IntelliJ IDEA, Eclipse, or VS Code)

Installation

  1. Clone the repository

    git clone https://github.com/earlbertmercado/restassured-petstore.git
    cd restassured-petstore
  2. Import as Maven project

    mvn clean install
  3. Update configurations (if needed) in src/main/resources/config.properties

  4. Add test data in src/test/resources/testdata/PetStoreTestData.xlsx

Running Tests

Run locally using Maven:

mvn clean test

Run specific test class:

mvn test -Dtest=PetTest

Run with specific test suite:

mvn test -DsuiteXmlFile=testng.xml

Running from IDE:

  • Right-click on testng.xml and click run
  • Or run PetTest.java directly

Running Tests via Docker

  • Build Docker image
    docker build -t restassured-petstore-tests .
  • Run all tests inside Docker container
    docker run --rm \
        -v $(pwd)/target:/app/target \
        -v $(pwd)/reports:/app/reports \
        -v $(pwd)/logs:/app/logs \
        restassured-petstore-tests
  • Run specific test inside Docker container
    docker run --rm \
        -v $(pwd)/target:/app/target \
        -v $(pwd)/reports:/app/reports \
        -v $(pwd)/logs:/app/logs \
        restassured-petstore-tests -Dtest=PetTest
    Reports and logs will be available locally after execution.

Running Tests via Jenkins

This project includes a Jenkinsfile for pipeline execution.

Jenkins requirements

  • Jenkins installed and running with Pipeline support enabled
  • Docker installed on Jenkins agent with proper execution permissions
  • Source control integration configured (e.g., GitHub with credentials or token)
  • Required plugins:
    • Pipeline
    • Git
  • Network access enabled for Docker image pulls and API endpoints under test

Reports

After test execution, detailed HTML reports are available at:

reports/PetStore_Test_Report.html

Sample log output:

[2026-01-04 00:13:34] INFO  ReportManager - Test started: testDeletePet
[2026-01-04 00:13:34] INFO  ReportManager - Deleting pet 1001
[2026-01-04 00:13:34] INFO  BaseClient - Executing DELETE request to: /pet/{petId}
[2026-01-04 00:13:36] INFO  ReportManager - Response: {"code":200,"type":"unknown","message":"1001"}
[2026-01-04 00:13:36] INFO  ReportManager - PASS: Test passed: testDeletePet
[2026-01-04 00:13:36] INFO  ReportManager - Completed test: testDeletePet
[2026-01-04 00:13:36] INFO  ReportManager - Test Suite Completed
[2026-01-04 00:13:36] INFO  ReportManager - Extent report flushed

About

A data-driven API test automation framework built with RestAssured and integrated with Docker and Jenkins for reliable CI execution, reporting, and logging.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published