Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore API Automation

Automated API test framework for the FakeRestAPI Online Bookstore (https://fakerestapi.azurewebsites.net), covering the Books endpoints (required) and Authors endpoints (bonus).

Built with Java 17 · Maven · RestAssured · TestNG · Allure, with a ready-to-run GitHub Actions CI pipeline that produces and publishes test reports.


Key Features

  • Clean, layered architecture (models → clients → tests) that promotes reuse and maintainability.
  • Shared request/response specifications, centralised configuration, and a Jackson-based (de)serialization setup.
  • Fluent builders and a TestDataFactory for independent, repeatable test data.
  • Happy-path and edge-case coverage (non-existent ids, malformed ids, malformed/empty bodies, boundary values), including data-driven tests.
  • Rich Allure reports with steps, severities, and request/response attachments.
  • CI pipeline that runs the suite and uploads Allure + Surefire reports on every push/PR.

Project Structure

allwyn/
├── pom.xml                     # Build, dependencies, plugins
├── testng.xml                  # Suite definition (Books + Authors)
├── .github/workflows/ci.yml    # CI/CD pipeline
└── src/test/
    ├── java/com/allwyn/bookstore/
    │   ├── base/               # BaseTest, Jackson mapper provider
    │   ├── clients/            # BooksClient, AuthorsClient (endpoint wrappers)
    │   ├── config/             # ConfigManager (layered configuration)
    │   ├── models/             # Book, Author POJOs (with builders)
    │   ├── specs/              # Shared RestAssured request/response specs
    │   ├── utils/              # TestDataFactory
    │   └── tests/
    │       ├── books/          # BooksCrudTests, BooksEdgeCaseTests
    │       └── authors/        # AuthorsCrudTests, AuthorsEdgeCaseTests
    └── resources/
        ├── config.properties   # Base URL, timeouts, logging
        └── allure.properties   # Allure results directory

Design notes

  • Clients wrap each endpoint and return the raw Response, keeping assertions in the tests where they belong (single responsibility).
  • ApiSpecs builds one consistent request spec (base URI, headers, timeouts, Allure filter) so tests never repeat transport setup (DRY).
  • ConfigManager resolves each value as system property → environment variable → config.properties, so the same code runs locally and in CI without edits (open/closed to new environments).
  • FakeRestAPI is a stateless mock — it echoes payloads but does not truly persist them. Assertions verify the contract (status codes, echoed fields, response shape), not cross-request persistence.

Prerequisites

  • JDK 17+ (java -version)
  • Maven 3.9+ (mvn -version)
  • Internet access to reach the FakeRestAPI host

Allure command-line is not required — the report is generated via the Allure Maven plugin.


Quick Start

# From the project root (the folder containing pom.xml)
mvn clean test

Run a single suite / class / method:

# Only the Authors tests via a custom suite file
mvn clean test -DsuiteXmlFile=testng.xml

# A single test class
mvn clean test -Dtest=BooksCrudTests

# A single test method
mvn clean test -Dtest=BooksCrudTests#getAllBooks_returnsNonEmptyList

Overriding configuration at runtime

Any key in config.properties can be overridden without editing files:

# System property
mvn clean test -Dbase.uri=https://fakerestapi.azurewebsites.net -Dlog.all=true

# Or environment variable (dots -> underscores, upper-cased)
#   BASE_URI, BASE_PATH, LOG_ALL, HTTP_SOCKET_TIMEOUT_MS ...

Test Report (Allure)

Generate and open the HTML report locally after a test run:

# Generate the static report into target/site/allure-maven-plugin
mvn io.qameta.allure:allure-maven:report

# Or generate + open in a browser
mvn io.qameta.allure:allure-maven:serve

Raw results are written to target/allure-results; the HTML report to target/site/allure-maven-plugin. Plain TestNG/Surefire results are also available under target/surefire-reports.


Test Coverage

Area Class Coverage
Books – happy path BooksCrudTests GET all, GET by id, POST, PUT, DELETE, create→get
Books – edge cases BooksEdgeCaseTests non-existent ids (404), malformed ids (400), malformed/empty body, boundary values
Authors – happy path AuthorsCrudTests GET all, GET by id, POST, PUT, DELETE
Authors – edge cases AuthorsEdgeCaseTests non-existent ids (404), malformed ids (400), no 5xx leakage

CI/CD (GitHub Actions)

The workflow at .github/workflows/ci.yml runs on every push/PR to main/master (and manual dispatch):

  1. Sets up JDK 17 (with Maven dependency caching).
  2. Runs mvn clean test.
  3. Always generates the Allure HTML report and uploads it, the raw Allure results, and the Surefire reports as build artifacts (downloadable from the run's Artifacts section).
  4. On main, optionally publishes the Allure report to GitHub Pages under /allure.

Because report steps use if: always(), you always get a report even when tests fail — while real test failures still fail the job so CI gates correctly. For a report-only run that must not fail the build, pass -DtestFailureIgnore=true.


Tech Stack

Concern Choice
Language Java 17
Build Maven
HTTP / assertions RestAssured + Hamcrest
Test runner TestNG (parallel by class)
JSON Jackson
Reporting Allure
CI GitHub Actions

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages