π¦ Enterprise Build Lifecycle & Dependency Graph Architecture
A solid API automation suite relies on a clean, predictable build configuration. REST Assured is modular by design; it depends on multiple libraries under the hood, including Groovy (for GPath JSON parsing), Apache HttpComponents (for wire networking), Hamcrest (for BDD assertions), and Jackson or Gson (for POJO object mapping). Without careful dependency management, teams often encounter classpath collision errors like NoSuchMethodError, conflicting Groovy runtimes, and incompatible Jackson versions across test runners. Whether building with Apache Maven or Gradle, structuring your dependencies, applying the correct test scopes, and configuring Surefire or Gradle Test runners is the foundation for reliable, headless execution across local developer workstations and CI/CD build agents.
ENTERPRISE REST ASSURED CLASSPATH TOPOGRAPHY:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β APPLICATION BUILD RUNNER (Maven Test Scope / Gradle testImplementation) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββ
β CORE TEST & ASSERTION RUNNERS β β REST ASSURED ARTIFACT ECOSYSTEM β
ββββββββββββββββββββββββββββββββββββββββββββββββ€ ββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ TestNG (org.testng:testng) β β β’ io.rest-assured:rest-assured (Core DSL) β
β OR JUnit 5 (org.junit.jupiter:junit-jupiterβ β β’ io.rest-assured:json-path (GPath Engine) β
β β’ Hamcrest (org.hamcrest:hamcrest) β β β’ io.rest-assured:xml-path (XPath Engine) β
β β’ AssertJ (org.assertj:assertj-core) β β β’ io.rest-assured:json-schema-validator β
ββββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββ
β β
ββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OBJECT MAPPING & DATA CONTRACT LAYER β
β βββ com.fasterxml.jackson.core:jackson-databind (POJO Serialization & Deserialization) β
β βββ com.fasterxml.jackson.datatype:jackson-datatype-jsr310 (Java 8 LocalDateTime support) β
β βββ org.projectlombok:lombok (Builder pattern & boilerplate reduction) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β REPORTING & LOGGING INFRASTRUCTURE β
β βββ io.qameta.allure:allure-testng / allure-rest-assured (Living HTML dashboards) β
β βββ org.slf4j:slf4j-simple / ch.qos.logback:logback-classic (Wire Logging Engine) β
β βββ org.aeonbits.owner:owner (Type-safe configuration & properties management) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
pom.xml file for REST Assured using Java 17/21, TestNG, Jackson Databind, Hamcrest, and JSON Schema Validator with explicit version properties.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nikita.automation</groupId>
<artifactId>rest-assured-enterprise-suite</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Dependency Versions -->
<rest-assured.version>5.4.0</rest-assured.version>
<testng.version>7.9.0</testng.version>
<jackson.version>2.17.0</jackson.version>
<hamcrest.version>2.2</hamcrest.version>
<lombok.version>1.18.32</lombok.version>
<owner.version>1.0.12</owner.version>
<allure.version>2.27.0</allure.version>
<surefire.version>3.2.5</surefire.version>
</properties>
<dependencies>
<!-- 1. REST Assured Core DSL -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<!-- 2. JSON Schema Validator -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
<!-- 3. TestNG Test Runner -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<!-- 4. Jackson Databind for POJO Serialization -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<!-- 5. Jackson JSR310 Date/Time Support -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<!-- 6. Hamcrest Matchers Library -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<!-- 7. Project Lombok for Builder Patterns -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- 8. Owner Library for Environment Config -->
<dependency>
<groupId>org.aeonbits.owner</groupId>
<artifactId>owner</artifactId>
<version>${owner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
build.gradle) and Kotlin DSL (build.gradle.kts), with test task customization and JVM arguments.
// ==============================================================================
// OPTION A: GRADLE GROOVY DSL (build.gradle)
// ==============================================================================
plugins {
id 'java'
id 'io.qameta.allure' version '2.11.2'
}
group = 'com.nikita.automation'
version = '1.0.0-SNAPSHOT'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
def restAssuredVersion = '5.4.0'
def jacksonVersion = '2.17.0'
def testngVersion = '7.9.0'
dependencies {
// REST Assured & Schema Validation
testImplementation "io.rest-assured:rest-assured:${restAssuredVersion}"
testImplementation "io.rest-assured:json-schema-validator:${restAssuredVersion}"
// TestNG Test Engine
testImplementation "org.testng:testng:${testngVersion}"
// Jackson Databind for POJO serialization
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}"
// Hamcrest Matchers
testImplementation 'org.hamcrest:hamcrest:2.2'
// Lombok for Model POJOs
compileOnly 'org.projectlombok:lombok:1.18.32'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
}
test {
useTestNG() {
suites 'src/test/resources/testng.xml'
}
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
}
}
// ==============================================================================
// OPTION B: GRADLE KOTLIN DSL (build.gradle.kts)
// ==============================================================================
// dependencies {
// testImplementation("io.rest-assured:rest-assured:5.4.0")
// testImplementation("io.rest-assured:json-schema-validator:5.4.0")
// testImplementation("org.testng:testng:7.9.0")
// testImplementation("com.fasterxml.jackson.core:jackson-databind:2.17.0")
// }
// tasks.test {
// useTestNG()
// }
maven-surefire-plugin to execute TestNG suites in parallel, bind suite XML files (testng.xml), capture system properties, and handle test failures in CI pipelines.
<build>
<plugins>
<!-- 1. Maven Compiler Plugin (Java 17 / Annotation Processors) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- 2. Maven Surefire Plugin (Test Execution Engine) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<!-- Target explicit TestNG XML configuration suite -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/suites/testng-regression.xml</suiteXmlFile>
</suiteXmlFiles>
<!-- Forward CLI system properties (e.g. -Denv=staging) to tests -->
<systemPropertyVariables>
<env>${env}</env>
<baseUrl>${baseUrl}</baseUrl>
</systemPropertyVariables>
<!-- Parallel thread configuration -->
<parallel>methods</parallel>
<threadCount>4</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
<!-- Never swallow logs on test failures -->
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
</plugins>
</build>
NoSuchMethodError.
<!-- ==============================================================================
COMMON ISSUE: Groovy version clash or conflicting Hamcrest 1.3 vs 2.2
SYMPTOM: java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch()
SOLUTION: Exclude transitive legacy hamcrest-core and declare modern Hamcrest 2.2
============================================================================== -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.4.0</version>
<scope>test</scope>
<exclusions>
<!-- Exclude legacy hamcrest-core if bundled by older transitive plugins -->
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Explicit modern Hamcrest dependency to enforce single canonical version -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<!-- DIAGNOSTIC COMMAND TO TRACE CONFLICTS -->
<!-- $ mvn dependency:tree -Dincludes=org.hamcrest:* -->
LocalDate and Instant fields without throwing InvalidDefinitionException.
// ==============================================================================
// STEP 1: POM.XML DEPENDENCIES REQUIRED FOR JACKSON DATABIND
// ==============================================================================
// <dependency>
// <groupId>com.fasterxml.jackson.core</groupId>
// <artifactId>jackson-databind</artifactId>
// <version>2.17.0</version>
// <scope>test</scope>
// </dependency>
// <dependency>
// <groupId>com.fasterxml.jackson.datatype</groupId>
// <artifactId>jackson-datatype-jsr310</artifactId>
// <version>2.17.0</version>
// <scope>test</scope>
// </dependency>
// ==============================================================================
// STEP 2: REST ASSURED CUSTOM OBJECT MAPPER INITIALIZATION
// ==============================================================================
package com.nikita.restassured.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.restassured.RestAssured;
import io.restassured.config.ObjectMapperConfig;
import io.restassured.config.RestAssuredConfig;
import org.testng.annotations.BeforeSuite;
public class CustomObjectMapperConfig {
@BeforeSuite
public void configureGlobalJacksonMapper() {
ObjectMapper customMapper = new ObjectMapper()
.registerModule(new JavaTimeModule()) // Supports LocalDateTime / Instant
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // Tolerant reader
RestAssured.config = RestAssuredConfig.config().objectMapperConfig(
ObjectMapperConfig.objectMapperConfig().jackson2ObjectMapperFactory(
(type, s) -> customMapper
)
);
System.out.println("[*] Global Jackson ObjectMapper initialized with JavaTimeModule.");
}
}
mvn test -Pstaging, dynamically switching base URIs and test suites.
<profiles>
<!-- 1. DEVELOPMENT ENVIRONMENT PROFILE -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env.target>development</env.target>
<env.baseUrl>https://dev-api.nikita-infotech.com/v1</env.baseUrl>
<suite.file>src/test/resources/suites/testng-smoke.xml</suite.file>
</properties>
</profile>
<!-- 2. STAGING PRE-RELEASE PROFILE -->
<profile>
<id>staging</id>
<properties>
<env.target>staging</env.target>
<env.baseUrl>https://staging-api.nikita-infotech.com/v1</env.baseUrl>
<suite.file>src/test/resources/suites/testng-regression.xml</suite.file>
</properties>
</profile>
<!-- 3. PRODUCTION READ-ONLY HEALTH CHECK PROFILE -->
<profile>
<id>prod</id>
<properties>
<env.target>production</env.target>
<env.baseUrl>https://api.nikita-infotech.com/v1</env.baseUrl>
<suite.file>src/test/resources/suites/testng-prod-health.xml</suite.file>
</properties>
</profile>
</profiles>
allure-maven and allure-rest-assured plugins. Automatically intercepts wire requests and generates rich HTML dashboards with request/response attachments upon test completion.
<!-- 1. ALLURE REST ASSURED ATTACHMENT FILTER -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-rest-assured</artifactId>
<version>2.27.0</version>
<scope>test</scope>
</dependency>
<!-- 2. ALLURE TESTNG RUNNER LISTENER -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.27.0</version>
<scope>test</scope>
</dependency>
<!-- 3. ALLURE REPORT BUILD PLUGIN -->
<build>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.12.0</version>
<configuration>
<reportVersion>2.27.0</reportVersion>
<resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
</configuration>
</plugin>
</plugins>
</build>
<!-- ==============================================================================
EXECUTION & LOCAL REPORT SERVER COMMANDS:
$ mvn clean test
$ mvn allure:serve (Generates report and serves on http://localhost:PORT)
============================================================================== -->
name: REST Assured API Regression Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
api-regression:
name: Execute REST Assured Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up OpenJDK 17 LTS
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven' # Caches ~/.m2 to accelerate builds
- name: Compile and Run REST Assured Tests
run: |
mvn clean test -Pstaging \
-Dsurefire.suiteXmlFiles=src/test/resources/suites/testng-regression.xml \
-DargLine="-Dfile.encoding=UTF-8"
- name: Archive Allure Results
uses: actions/upload-artifact@v4
if: always()
with:
name: allure-raw-results
path: target/allure-results
retention-days: 14
- name: Publish TestNG Surefire Test Summary
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/**/*.xml
REST ASSURED DEPENDENCY & BUILD TOOL SPECIFICATION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β DEPENDENCY / ARTIFACT β MAVEN COORDINATES β GRADLE DIRECTIVE β PRIMARY OPERATIONAL ROLE β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββββββββββββββββ€
β REST Assured Core β io.rest-assured:rest-assured β testImplementationβ Fluent Given/When/Then DSL β
β JSON Schema Validator β io.rest-assured:json-schema..β testImplementationβ Draft-07 schema validation β
β TestNG Engine β org.testng:testng β testImplementationβ Test runner, DataProviders β
β Jackson Databind β com.fasterxml.jackson.core:..β testImplementationβ POJO serialization / mapping β
β Jackson JSR-310 β com.fasterxml.jackson.data.. β testImplementationβ Java 8 LocalDate / Instant β
β Hamcrest Library β org.hamcrest:hamcrest β testImplementationβ Assertions (equalTo, hasItem) β
β Project Lombok β org.projectlombok:lombok β compileOnly/proc β Builder pattern, clean POJOs β
β Owner Configuration β org.aeonbits.owner:owner β testImplementationβ Type-safe properties manager β
β Allure REST Assured β io.qameta.allure:allure-rest.β testImplementationβ Request/Response attachments β
β Maven Surefire Plugin β maven-surefire-plugin (3.2.x)β test { useTestNG }β Parallel execution engine β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ€
β TOP 5 DEPENDENCY MANAGEMENT BEST PRACTICES: β
β 1. Always scope automation dependencies to test: Keeps production application artifacts lean and clean. β
β 2. Exclude legacy hamcrest-core: Avoid NoSuchMethodError conflicts by using canonical Hamcrest 2.2+. β
β 3. Include jackson-datatype-jsr310: Support modern Java 8+ datetime types in your POJO data models. β
β 4. Leverage Maven ~/.m2 caching in CI/CD: Cuts pipeline execution times significantly. β
β 5. Parameterize suite files via Surefire: Use -DsuiteXmlFile to switch between smoke and regression. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ