Keploy logo
Clojure logo

Keploy as a Clojure testing framework

Keploy tests Clojure services by recording real HTTP and database traffic from a running process, then replaying it as assertions. There is no var to rebind and nothing to mock by hand, because capture happens below the JVM at the socket.

Generate Clojure tests free
keploy record -c "java -jar target/app-standalone.jar"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Clojure team

Any Clojure service, unchanged

Keploy runs the uberjar. Ring, Pedestal, Reitit and a bare Jetty adapter all record identically, because capture is at the socket rather than inside the handler stack.

  • Clojure 1.10 and above
  • Ring, Pedestal, Reitit
  • Leiningen or deps.edn
  • No plugin needed
The problem

Why Clojure 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 Clojure: by hand, with clojure.test + with-redefs, or with Keploy

clojure.test + with-redefs describes the exchange by hand and still needs the dependency supplied. Keploy records both halves once and replays them with nothing running.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Clojure 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
orders_test.clj
hand-written
(ns app.orders-test
(:require [clojure.test :refer [deftest is]]
[app.orders :as orders]
[app.db :as db]
[app.payments :as payments]))
 
(deftest confirms-an-order
;; Rebound for this form only, and thread-local: anything the handler
;; does on another thread escapes the rebinding entirely.
(with-redefs [db/find-order (fn [_] {:id "o-1" :total 4200 :status "NEW"})
payments/authorize (fn [_] {:status "AUTHORIZED"})]
(let [res (orders/confirm {:params {:id "o-1"}})]
(is (= 200 (:status res)))
(is (= "CONFIRMED" (get-in res [:body :status]))))))

with-redefs rebinds the var for this form only, so next.jdbc never runs.

clojure.test + with-redefs1–2 hours
orders_wiremock_test.clj
tool-assisted
(ns app.orders-wiremock-test
(:require [clojure.test :refer [deftest is use-fixtures]]
[app.orders :as orders])
(:import [com.github.tomakehurst.wiremock WireMockServer]))
 
(def server (WireMockServer. 8787))
 
(use-fixtures :once
(fn [f]
(.start server)
;; One stub mapping per outbound URL, written by hand.
(.stubFor server (-> (post (url-equal-to "/v1/payment_intents/tok_123/confirm"))
(.willReturn (ok-json "{\"status\":\"AUTHORIZED\"}"))))
(f)
(.stop server)))
 
;; A real Postgres is still required, migrated and seeded per run.
(deftest confirms-an-order
(let [res (orders/confirm {:params {:id "o-1"}})]
(is (= 200 (:status res)))))

WireMock serves the upstream. The database is still a real one.

With Keploy~5 minutes
keploy/test-set-0/test-1.yaml
auto-generated
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/o-1/confirm
resp:
status_code: 200
body: '{"id":"o-1","status":"CONFIRMED","total":4200}'
assertions:
noise:
- body.confirmedAt
---
kind: Postgres
spec:
query: select id, total, status from orders where id = $1
rows:
- { id: "o-1", total: 4200, status: "NEW" }
---
kind: Http
spec:
request:
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm
response:
body: '{"status":"AUTHORIZED"}'

Recorded from one real request. Nothing here was typed by hand.

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

Keploy vs the alternatives

Clojure 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 Clojure app once, replay it forever

Keploy sits below your Clojure 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 Clojure service and captures the dependency calls it makes.

Clojure logo
Your Clojure app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
Outbound HTTP
Outbound HTTPEvery clj-http and hato call
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 Clojure, with zero config

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

Quick start

Your first Clojure test suite in under five minutes

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

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    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 every socket it opens.

    keploy record -c "java -jar target/app-standalone.jar"
  3. 3Exercise the paths you care about

    Use curl, your frontend, or an existing smoke script. Every request becomes a test case with its Clojure calls captured alongside it.

    curl -X POST localhost:3000/orders/o-1/confirm
    curl localhost:3000/orders/o-1
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "java -jar target/app-standalone.jar" --delay 20

Ready to try it on your own Clojure service?

Ecosystem

Works with the rest of your Clojure stack

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

FAQ

Clojure 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.