Keploy logo
DynamoDB logo

Keploy as a DynamoDB testing framework

Keploy mocks DynamoDB by recording the AWS SDK's HTTP traffic, capturing the items, capacity metadata, and pagination tokens the service returned, then replaying them in tests. No DynamoDB Local runs, no table is defined, and no AWS credentials are needed.

Generate DynamoDB tests free
keploy record -c "./orders-service"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a DynamoDB team

Captured at the DynamoDB HTTP API

The AWS SDK talks to DynamoDB over HTTPS with a JSON protocol, so Keploy records the real exchange — items in their attribute-value encoding, consumed capacity, and LastEvaluatedKey included.

  • Below every AWS SDK language binding
  • Attribute-value types preserved
  • ConsumedCapacity captured
  • Pagination tokens replayed
The problem

Why DynamoDB 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 DynamoDB: by hand, with DynamoDB Local, or with Keploy

DynamoDB Local is a separate implementation that still needs tables created per environment. Keploy records the managed service once and replays exactly what it returned.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for DynamoDB 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_store_stub.go
hand-written
// Hand-written stub: marshalling is never exercised.
package store
 
type StubOrderStore struct{}
 
func (StubOrderStore) Get(id string) (Order, error) {
// The SDK would return N as a string and marshal it. This does not.
return Order{ID: id, AmountMinor: 4200, State: "NEW"}, nil
}
 
func (StubOrderStore) Put(o Order) error {
// No key schema, no condition expression, no capacity accounting.
return nil
}

Attribute-value marshalling, condition expressions, and key schema validation are all absent, so a type coercion bug reaches production unseen.

DynamoDB Local1–2 hours
order_store_test.go
tool-assisted
// DynamoDB Local: a separate implementation of the API.
package store
 
import (
"context"
"testing"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
)
 
func TestReadsAnItem(t *testing.T) {
client := localClient(t) // points at localhost:8000
 
// Every environment recreates the table and its indexes.
mustCreateTable(t, client, ordersTableSpec)
mustPutItem(t, client, ordersItem("ord_1", 4200, "NEW"))
 
order, err := New(client).Get(context.Background(), "ord_1")
if err != nil || order.AmountMinor != 4200 {
t.Fatalf("got %+v err %v", order, err)
}
}

Real SDK marshalling against a local endpoint — and it needs a running process plus table and index creation before every run.

With Keploy~5 minutes
mocks.yaml
auto-generated
# Recorded with: keploy record -c './orders-service'
# The DynamoDB response, captured at the HTTP API layer.
version: api.keploy.io/v1beta1
kind: Http
name: mock-2
spec:
request:
method: POST
url: https://dynamodb.example.com/
header:
X-Amz-Target: DynamoDB_20120810.GetItem
body: '{"TableName":"orders","Key":{"id":{"S":"ord_1"}}}'
response:
status_code: 200
body:
Item:
id: { S: "ord_1" }
# DynamoDB returns numbers as strings. The SDK marshals them.
amount_minor: { N: "4200" }
state: { S: "NEW" }
ConsumedCapacity:
TableName: "orders"
CapacityUnits: 0.5

The N value replays as the string DynamoDB really sends, so the SDK's marshalling runs on every replay instead of being bypassed.

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

Keploy vs the alternatives

DynamoDB testing tools, compared

The options a team on document and wide-column stores 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 DynamoDB app once, replay it forever

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

DynamoDB clients Keploy records, driver by driver

Keploy captures DynamoDB at the wire protocol, so 4 of these 6 clients need no adapter, no test double, and no DynamoDB instance in CI.

Quick start

Your first DynamoDB test suite in under five minutes

Every command below runs against your existing DynamoDB 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 "./orders-service"
  3. 3Exercise the paths you care about

    Run the app against your development table. Every GetItem, Query, and PutItem, with the response the service returned, is captured together.

    curl localhost:8080/orders/ord_1
    curl -X POST localhost:8080/orders/ord_1/confirm -d '{"paymentToken":"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 "./orders-service" --delay 8

Ready to try it on your own DynamoDB service?

Ecosystem

Works with the rest of your DynamoDB stack

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

FAQ

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