Keploy logo
Java logo

Keploy as a Java testing framework

Keploy tests Java applications by recording real HTTP and JDBC traffic at the network layer, then replaying it as assertions. You add no annotations, no test dependencies, and no Docker containers — Keploy runs your existing JAR and turns observed behaviour into a regression suite.

Generate Java tests free
keploy record -c "java -jar orders.jar"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Java team

Any JVM service, unchanged

Keploy runs the JAR you already deploy. Spring Boot, Quarkus, Micronaut, Dropwizard, and plain servlet apps all record the same way, because capture happens at the socket rather than inside the framework.

  • JVM 8 and above, any build tool
  • No annotations and no test-scoped dependencies
  • Works with an embedded server or a WAR on Tomcat
  • Reactive and blocking endpoints record identically
The problem

Why Java integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing Java: by hand, with JUnit + Mockito, or with Keploy

JUnit and Mockito describe behaviour you already understand. Keploy derives it from traffic your service already served — so coverage grows without anyone writing a test class.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Java vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
OrderControllerTest.java
hand-written
// Hand-written: fixtures, fakes, and assertions all by hand.
package com.acme.orders;
 
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
 
class OrderControllerTest {
 
private FakeOrderRepository repo;
private FakePaymentClient payments;
private OrderController controller;
 
@BeforeEach
void setUp() {
repo = new FakeOrderRepository();
payments = new FakePaymentClient();
payments.stub("tok_123", "AUTHORIZED");
repo.seed(new Order("ord_1", 4200, "NEW"));
controller = new OrderController(repo, payments);
}
 
@Test
void confirmsAnAuthorizedOrder() {
var response = controller.confirm("ord_1", "tok_123");
 
assertEquals(200, response.status());
assertEquals("CONFIRMED", response.body().state());
assertNotNull(response.body().confirmedAt());
}
}

Two fake classes exist only to serve this test. Both encode a guess about the real dependency, and neither fails when that guess goes stale.

JUnit + Mockito1–2 hours
OrderControllerIT.java
tool-assisted
// JUnit 5 + Mockito + Testcontainers.
package com.acme.orders;
 
import org.junit.jupiter.api.*;
import org.mockito.Mock;
import org.testcontainers.containers.MySQLContainer;
import static org.mockito.Mockito.*;
 
class OrderControllerIT {
 
static MySQLContainer<?> mysql = new MySQLContainer<>("mysql:8.0");
 
@Mock PaymentClient payments;
 
@BeforeAll
static void boot() { mysql.start(); }
 
@AfterAll
static void stop() { mysql.stop(); }
 
@Test
void confirmsAnAuthorizedOrder() {
when(payments.authorize("tok_123")).thenReturn("AUTHORIZED");
 
var response = controller.confirm("ord_1", "tok_123");
 
assertEquals("CONFIRMED", response.body().state());
verify(payments).authorize("tok_123");
}
}

Correct and idiomatic — but the runner now needs a Docker daemon, and the payment stub is still a hand-written assumption about the upstream contract.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c 'java -jar orders.jar'
# Nobody wrote this file. Keploy captured it from a real request.
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/ord_1/confirm
header:
Content-Type: application/json
body: '{"paymentToken":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
amountMinor: 4200
confirmedAt: "2026-09-02T11:04:18Z"
# Fields that change every run — excluded from assertions.
noise:
- body.confirmedAt
- header.X-Request-Id
# The JDBC and HTTP calls this request made, mocked on replay.
mocks:
- kind: SQL
operation: "SELECT id, amount_minor, state FROM orders WHERE id = ?"
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm

The mocks block is the real payment response and the real JDBC result set. When either contract changes, the recording changes with it.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

Java testing tools, compared

The options a team on the JVM actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your Java app once, replay it forever

Keploy sits below your Java process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a Java service and captures the dependency calls it makes.

Java logo
Your Java app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+4 more Java dependencies
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for Java, with zero config

7 of the 8 dependencies a typical Java service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first Java test suite in under five minutes

Every command below runs against your existing Java service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    One binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches the sockets.

    keploy record -c "java -jar target/orders-1.0.0.jar"
  3. 3Exercise the endpoints you care about

    Use curl, Postman, your frontend, or a smoke script. Every request becomes a test case with its dependency calls attached.

    curl -X POST localhost:8080/orders/ord_1/confirm -H 'Content-Type: application/json' -d '{"paymentToken":"tok_123"}'
  4. 4Replay the suite in CI

    Replay needs no database and no broker, so it drops into any runner as a single step.

    keploy test -c "java -jar target/orders-1.0.0.jar" --delay 10

Ready to try it on your own Java service?

Ecosystem

Works with the rest of your Java stack

Keploy records at the network layer, so framework and driver choices inside your Java app do not change how it captures traffic.

  • Spring Boot logo

    Spring Boot

    Recorded through the embedded server — no test slices needed.

  • Quarkus logo

    Quarkus

    Native or JVM mode; capture happens outside the runtime.

  • Hibernate logo

    Hibernate

    JPA queries are captured as the SQL they emit, not as ORM calls.

  • Apache Maven logo

    Apache Maven

    Replay is a CLI step, so no plugin or surefire config changes.

  • Gradle logo

    Gradle

    Same — wrap bootRun or the built JAR and record.

  • Apache Tomcat logo

    Apache Tomcat

    Works with a WAR on a standalone Tomcat as well as embedded.

FAQ

Java testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.