Keploy logo
Elixir logo

Keploy as a Elixir testing framework

Keploy tests Elixir services by recording real HTTP and Ecto traffic from a running BEAM process, then replaying it as assertions. There are no Mox behaviours to define, no Bypass server to start, and no Ecto sandbox transaction per test.

Generate Elixir tests free
keploy record -c "mix phx.server"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Elixir team

Any Elixir service, unchanged

Keploy runs the app through mix or a release. Phoenix, Plug, and bare Cowboy services record the same way, because capture is at the socket rather than inside the Plug pipeline.

  • Elixir 1.14 and above
  • mix phx.server or a release
  • Phoenix, Plug, and Cowboy
  • Umbrella apps included
The problem

Why Elixir 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 Elixir: by hand, with ExUnit + Mox, or with Keploy

Mox needs a behaviour to define against and Bypass needs a Plug you write. Keploy captures outside the process, so neither the behaviour nor the stub server has to exist.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Elixir 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
order_service_test.exs
hand-written
# Hand-written: a stub module matching a behaviour.
defmodule Acme.StubRepo do
@behaviour Acme.OrderRepo
 
@impl true
def get(id), do: {:ok, %Acme.Order{id: id, amount_minor: 4200, state: "NEW"}}
end
 
defmodule Acme.OrderServiceTest do
use ExUnit.Case, async: true
 
test "confirms an authorized order" do
assert {:ok, order} =
Acme.OrderService.confirm(Acme.StubRepo, "ord_1", "tok_123")
 
assert order.state == "CONFIRMED"
end
end

The behaviour exists so this stub can satisfy it. Nothing checks that its return shape still matches what Postgres and Stripe actually send.

ExUnit + Mox1–2 hours
order_controller_test.exs
tool-assisted
# ExUnit + Mox + Bypass + the Ecto sandbox.
defmodule AcmeWeb.OrderControllerTest do
use AcmeWeb.ConnCase, async: true
import Mox
 
setup :verify_on_exit!
 
test "confirms an authorized order", %{conn: conn} do
insert(:order, id: "ord_1", amount_minor: 4200)
 
# A literal that will not change when Stripe does.
expect(Acme.PaymentsMock, :authorize, fn "tok_123" ->
{:ok, %{"status" => "AUTHORIZED"}}
end)
 
conn = post(conn, ~p"/orders/ord_1/confirm", payment_token: "tok_123")
 
assert json_response(conn, 200)["state"] == "CONFIRMED"
end
end

Idiomatic and concurrency-safe — and it needs a behaviour, a mock module, a migrated database, and a Stripe body typed out by hand.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c 'mix phx.server'
# 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
body: '{"paymentToken":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
amountMinor: 4200
noise:
- body.confirmedAt
mocks:
- kind: Postgres
operation: "SELECT id, amount_minor, state FROM orders WHERE id = $1"
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm

The SQL Ecto emitted and Stripe's real response are both recorded, so no behaviour had to be introduced and no sandbox transaction was needed.

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

Keploy vs the alternatives

Elixir testing tools, compared

The options a team on the BEAM 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 Elixir app once, replay it forever

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

Elixir logo
Your Elixir app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
Outbound HTTP
Outbound HTTPAny HTTP client call the service makes
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 Elixir, with zero config

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

Quick start

Your first Elixir test suite in under five minutes

Every command below runs against your existing Elixir 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 "mix phx.server"
  3. 3Exercise the paths you care about

    Drive the running server. Every request becomes a test case with its Ecto queries and HTTP calls captured alongside.

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

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

    keploy test -c "mix phx.server" --delay 12

Ready to try it on your own Elixir service?

Ecosystem

Works with the rest of your Elixir stack

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

FAQ

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