Responsive

API Testing Using RestAssured And Testkube

Published
July 20, 2025
Bruno Lopes
Product Leader
Testkube

Table of Contents

Unlock Better Testing Workflows in Kubernetes — Try Testkube for Free

Subscribe to our monthly newsletter to stay up to date with all-things Testkube.

You have successfully subscribed to the Testkube newsletter.
You have successfully subscribed to the Testkube newsletter.
Oops! Something went wrong while submitting the form.
Last updated
July 19, 2025
Bruno Lopes
Product Leader
Testkube
Share on X
Share on LinkedIn
Share on Reddit
Share on HackerNews
Copy URL

Table of Contents

RestAssured & Testkube TL;DR

TL;DR

RestAssured & Testkube for API Testing

  • 1
    API-first design is trending - Modern applications prioritize designing APIs before implementing services, making them first-class citizens for consistency and scalability
  • 2
    RestAssured challenges in Kubernetes - While RestAssured is a powerful Java API testing tool, running it in Kubernetes environments creates complexity around setup, scaling, isolation, and CI/CD integration
  • 3
    Testkube solves K8s testing problems - Testkube is a Kubernetes-native testing framework that converts tests into Kubernetes CRDs and enables declarative, version-controlled testing workflows
  • 4
    Simple integration workflow - You can create RestAssured test workflows in Testkube using Gradle, specify your Git repo source, and execute tests with real-time logging and artifact collection
  • 5
    End-to-end API testing solution - Combining RestAssured with Testkube provides a complete workflow for API testing that leverages Kubernetes' power while avoiding its complexities

Modern applications adopt API-first design, which provides seamless communication between services and clients. This approach is becoming increasingly popular, where APIs are designed and developed before the implementation of the actual services. This ensures that APIs are treated as first-class citizens, fostering consistency, reusability, and scalability.

Ensuring the reliability and availability of these APIs is crucial, as they are the backbone of critical business processes. API testing helps validate these services and ensure they work as expected and meet the set standards. 

Considering the Java ecosystem, one popular tool for testing APIs is RestAssured. Tailored for the Java ecosystem, RestAssure is a popular tool for API testing. However, managing and executing these tests is complicated as we move towards containerized applications. 

In this post, we’ll examine these challenges and learn how to use RestAssured with Testkube for API testing. 

RestAssured

RestAssured is a Java tool for testing APIs using Java libraries. It integrates well with build tools like Maven and Gradle, making it easy to work with. It enables automation testing of APIs by allowing developers to send simple HTTP requests and focus solely on testing the API without worrying about anything else. 

Below are some noteworthy features of RestAssured:

  • RestAssured integrates easily with other testing frameworks, such as JUnit and TestNG, making it easier to include API tests along with other automated tests. 
  • It supports all HTTP methods, enabling you to perform complete testing of CRUD-based functionalities.
  • It has out-of-the-box support for XML and JSON. This means you can use features like XMLPath and JSONPath to extract variables from responses. 
  • There is a robust set of assertion methods to validate the responses.

You can read more about RestAssured here.

Challenges using RestAssured in Kubernetes

RestAssured is a powerful tool for testing APIs in CI pipelines and local environments. However, running these tests in a Kubernetes environment has different challenges. 

  • Setting up environments for tests with required dependencies and configurations can be complex. 
  • Managing and scaling tests based on the load in the Kubernetes cluster can be challenging. 
  • Avoiding interference, maintaining consistency, and running tests in isolation is problematic. 
  • Integrating with CI/CD tools and maintaining test artifacts and logs can be a painful process.

Let us see how Testkube helps overcome these challenges. 

Using RestAssured With Testkube

Testkube is a Kubernetes-native testing framework that allows you to create testing workflows in a declarative, version-controlled way. It integrates with most of the CI/CD tools and helps you automate the initiation, execution, and validation of tests as part of automated workflows. 

Testkube allows you to plug in any testing tool and leverage the power of Kubernetes. It converts your tests, test suites, and other artifacts into Kubernetes CRDs, allowing you to manage them declaratively. 

With Testkube, you can create Test Workflows that include everything from provisioning necessary infrastructure components to integrating seamlessly with other testing tools and orchestrating complex tests. Refer to our Test Workflows documentation to learn more. 

Let's examine how to use RestAssured with Testkube for API testing. We’ll create a Test workflow using Gradle and integrate RestAssure tests into it. This repo contains all the required files for this example.

Pre-requisites

Once the prerequisites are in place, you should have a target Kubernetes cluster ready with a Testkube agent configured. 

Creating a Test Workflow

Navigate to the Test Workflows tab and click on “Add a new test workflow”

This will provide you with three options:

  • Create from scratch - use the wizard to create a Test Workflow.
  • Start from an example - use existing k6, cypress, and playwright examples
  • Import from yaml - import your own Test Workflow.

We’ll choose the “create from scratch” option to create this workflow.

  • Provide a name for the workflow and choose the type as Gradle. 
  • Provide the run command. In this case, we’ll provide gradlew test
  • Provide a Gradle version, we’ll use 8.5.0-jdk11

On the next screen, provide the source for the test file. This can either be a Git Repo, String or a file. In this case, we’ll use a Git repo. 

On the next screen, it will generate the yaml spec file and display the output. 

kind: TestWorkflow

apiVersion: testworkflows.testkube.io/v1

metadata:

  name: gradle-restassured

  namespace: testkube

  labels:

    test-workflow-templates: "yes"

spec:

  use:

  - name: official--gradle--beta

    config:

      run: ./gradlew test

      version: 8.5.0-jdk11

  content:

    git:

      uri: https://github.com/kubeshop/testkube-examples.git

      revision: main

      paths:

      - RestAssured Test Using Gradle

  container:

    workingDir: /data/repo/RestAssured Test Using Gradle

  steps:

  - artifacts:

      workingDir: /data/repo/RestAssured Test Using Gradle/app/build/

      paths:

      - '**/*'

The yaml file is self-explanatory as it lists down the details you’ve provided in the yaml. We have added extra parameters for artifacts that will collect the reports generated by RestAssured and store them. 

Below is the RestAssured test file that explains what we are testing.

package org.example;

import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class ApiTest {
    @Test
    public void testGetEndpoint() {
        RestAssured.baseURI = "https://jsonplaceholder.typicode.com";

        given().
            when().
            get("/posts/1").
            then().
            statusCode(200).
            body("userId", equalTo(1)).
            body("id", equalTo(1)).
            body("title", not(empty())).
            body("body", not(empty()));
    }
}

The test checks for the response from https://jsonplaceholder.typicode.com endpoint and validates if the response.

The repo contains other files, including test steps and a test runner, which contain related code for executing the RestAssured test using Gradle.

Click on “Create” to create the test workflow.

Executing the Test Workflow

Once the workflow is ready, you’ll see the newly created test workflow on the screen. Click on it and click “Run Now” to start the workflow.

You’ll see the workflow executing along with the real-time logs of every step. 

You’ll see the test result based on the test execution. In this case, you’ll see the test pass.

Since we have configured the artifacts for this, you can navigate to the artifacts tab and look at the reports generated by RestAssured. Testkube saves these reports for every execution making it easier to analyze the tests.

This was a simple demo of creating a RestAssured Test Workflow using Gradle for Kubernetes testing. To take advantage of test workflows more, you can create custom workflows and import them to Testkube.

Summary

In this post we looked at how API first design approach is getting popular. Many Java applications are also adopting this design principle, and tools like RestAssured are gaining popularity in testing APIs. We also looked at RestAssured and the complexities of running it on Kubernetes. 

We then saw how using RestAssured with Testkube, you can create an end-to-end workflow for API testing leveraging the power of Kubernetes.

Visit the Testkube website to learn more about the other testing tools you can integrate with. If you struggle with anything, feel free to post a note in our active Slack community.

Top 5 Most Important RestAssured API Testing FAQs

RestAssured API Testing FAQs

Essential questions about REST API testing with Java

RestAssured is a Java-based library designed specifically for testing RESTful APIs. It provides a powerful, fluent syntax that makes writing API tests intuitive and readable for Java developers.

Key features that make RestAssured popular for API testing:

  • Fluent syntax: Write readable test code with method chaining
  • HTTP method support: Full support for GET, POST, PUT, DELETE, PATCH, and other HTTP methods
  • Framework integration: Seamless integration with JUnit, TestNG, and other testing frameworks
  • Response validation: Built-in assertions for JSON and XML response validation
  • Authentication support: Built-in support for OAuth, Basic Auth, and custom authentication schemes
  • Request/Response logging: Detailed logging capabilities for debugging and monitoring

RestAssured simplifies the process of sending HTTP requests, parsing responses, and validating API behavior, making it an ideal choice for automated API testing in Java environments.

Running RestAssured tests in Kubernetes environments introduces several unique challenges that don't exist in traditional testing setups:

  • Environment setup complexity: Managing dependencies, configurations, and environment variables across multiple containers and services
  • Scalability constraints: Running large test suites within resource-constrained Kubernetes clusters while avoiding impact on other workloads
  • Test isolation: Ensuring tests don't interfere with each other when running concurrently in shared cluster environments
  • Network connectivity: Handling service discovery, internal DNS resolution, and network policies that affect API endpoint accessibility
  • Artifact management: Collecting and preserving test results, logs, and reports across distributed pod executions
  • CI/CD integration: Coordinating test execution with deployment pipelines while managing multiple CI/CD tools and their specific requirements
  • Resource management: Properly configuring CPU and memory limits to prevent test pods from consuming excessive cluster resources

These challenges require specialized tools and approaches to effectively manage RestAssured test execution in containerized environments.

Testkube provides a Kubernetes-native testing platform that simplifies running RestAssured tests in containerized environments through declarative test orchestration.

Key benefits of using Testkube for RestAssured testing:

  • Declarative test management: Define and manage tests using Kubernetes Custom Resource Definitions (CRDs) for consistent, version-controlled test configurations
  • Git integration: Store test code in Git repositories and automatically sync changes without manual deployment steps
  • Workflow orchestration: Create complex test workflows that combine multiple RestAssured test suites with other testing tools
  • Artifact collection: Automatically collect and store test reports, logs, and other artifacts from test executions
  • CI/CD pipeline integration: Seamlessly integrate with existing CI/CD tools through webhooks, APIs, and pipeline triggers
  • Resource isolation: Run tests in isolated pods with proper resource allocation and cleanup
  • Real-time monitoring: Monitor test execution progress and view logs in real-time through the Testkube dashboard
  • Scalable execution: Automatically scale test execution based on cluster resources and test requirements

This eliminates the need for custom infrastructure setup and provides a standardized approach to API testing in Kubernetes environments.

Creating a RestAssured test workflow in Testkube with Gradle involves several straightforward steps:

  • Select Gradle as test type: Choose Gradle from the available test executor types in Testkube
  • Configure Git repository: Provide the Git repository URL containing your RestAssured test files and Gradle build configuration
  • Define execution command: Specify the Gradle command to run your tests, typically ./gradlew test or ./gradlew clean test
  • Set Gradle version: Configure the specific Gradle version required for your project to ensure compatibility
  • Configure artifact collection: Optionally specify paths for collecting test reports and artifacts:
    • Test reports: build/reports/tests/test/**/*
    • Build artifacts: build/libs/**/*
    • Custom outputs: Any additional files your tests generate
  • Environment variables: Set any required environment variables for test execution (API endpoints, credentials, etc.)
  • Resource allocation: Configure CPU and memory limits for the test execution pods

Testkube automatically generates a YAML specification for your workflow, which can be version-controlled and executed consistently across different environments within your Kubernetes cluster.

Yes, Testkube provides comprehensive capabilities for analyzing test reports and logs from RestAssured test executions.

Available analysis features include:

  • Artifact storage: All test artifacts generated during RestAssured executions are automatically collected and stored:
    • JUnit XML reports with detailed test results
    • HTML reports with formatted test summaries
    • Custom log files and debugging information
    • Screenshots or other test-generated files
  • Real-time log viewing: Monitor test execution progress with live log streaming during test runs
  • Historical analysis: Access and compare results from previous test executions to identify trends and regressions
  • Dashboard integration: View test results and metrics through the Testkube web UI with filtering and search capabilities
  • API access: Programmatically retrieve test results and artifacts through Testkube's REST API for custom reporting solutions
  • Export capabilities: Download artifacts and reports for offline analysis or integration with external reporting tools
  • Alerting integration: Set up notifications for test failures or performance degradations based on RestAssured test results

This comprehensive reporting and analysis capability ensures you have full visibility into your API test results and can quickly identify and resolve issues.

About Testkube

Testkube is a test execution and orchestration framework for Kubernetes that works with any CI/CD system and testing tool you need. It empowers teams to deliver on the promise of agile, efficient, and comprehensive testing programs by leveraging all the capabilities of K8s to eliminate CI/CD bottlenecks, perfecting your testing workflow. Get started with Testkube's free trial today.