Contribution Guide
Welcome to the world of Keploy development! This guide will help you set up Keploy locally.
1. Setting Up Your Platform:
Keploy built from source intercepts with eBPF, so to record an app with your own build on macOS or Windows, you'll work inside a Linux VM. (To just use Keploy, you don't need one: it runs natively on macOS and Windows — see Installing Keploy below.)
Note: Linux Users are good to go.
2. Pre-requisites:
First things first, ensure you have Golang installed.
3. Clone Keploy Repository:
Time to get your hands on Keploy!:
git clone https://github.com/keploy/keploy.git && cd keploy
go mod download
Once done, build the binary
go build -race -tags=viper_bind_struct -o keploy .
sudo mv keploy /usr/local/bin/
sudo chmod +x /usr/local/bin/keploy
Now we have successfully set up Keploy. Let’s test it with the sample app.
Keploy operates in two modes:
record: Capture Keploy test cases from API calls.test: Execute recorded test cases and validate assertions.
The Keploy CLI operates by capturing all network traffic between your application and its dependencies.
It meticulously records API calls, database queries, and any other interactions your application engages in.
Once the recording phase is complete, Keploy can effortlessly generate test cases and data mocks in YAML format.
If you don't have any samples app, you can use the gin-mongo URL Shortener sample application:
Let's clone sample app repo:
git clone https://github.com/keploy/samples-go.git && cd samples-go/gin-mongo
go mod download # Download dependencies:
go build -o gin-mongo-binary # Generate binary of the application:
4. Now let's try running keploy:
Capturing Test Cases:
sudo keploy record -c "path/to/go/binary"
Running Test Cases:
sudo keploy test -c "path/to/go/binary" --delay 10
Note: Use the --debug flag to run Keploy in debug mode for detailed logs.
Also you can Test Locally Built Docker Image:
Build Docker Image:
Note: Run the below command inside the keploy repository and make sure there is no directory by the name of keploy inside the main keploy repository.
sudo docker image build -t ghcr.io/keploy/keploy:v2-dev .
Remember setting up the Keploy binary. See Setup Keploy using Binary for details.
Capture Test Cases:
sudo keploy record -c "docker run -p -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <imageName>"
Running Test Cases:
sudo keploy test -c "docker run -p -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <imageName>" --delay 10
There you have it! With this guide, you're all set to dive into Keploy development.
Happy testing! 🧪🔍💻
Note :- Run
go run github.com/99designs/gqlgen generate --config pkg/graph/gqlgen.ymlto generate the graphql server stubs which can be used when working with unit testing libraries like JUnit, PyTest, etc..
Hope this helps you out, if you still have any questions, reach out to us on Slack.
Installing Keploy
To install the released Keploy binary alongside your local build:
- Linux
- macOS
- Windows
Make sure your Linux kernel version is 5.10 or higher.
👉 Choose your preferred method:
- Native
- Docker
1. Install Keploy
curl --silent -O -L https://keploy.io/install.sh && source install.sh
2. Once done, you should see something like this:
▓██▓▄
▓▓▓▓██▓█▓▄
████████▓▒
▀▓▓███▄ ▄▄ ▄ ▌
▄▌▌▓▓████▄ ██ ▓█▀ ▄▌▀▄ ▓▓▌▄ ▓█ ▄▌▓▓▌▄ ▌▌ ▓
▓█████████▌▓▓ ██▓█▄ ▓█▄▓▓ ▐█▌ ██ ▓█ █▌ ██ █▌ █▓
▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌ ██ █▓ ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀ █▓█
▓▌ ▐█▌ █▌
▓
Available Commands:
example Example to record and test via keploy
config --generate generate the keploy configuration file
record record the keploy testcases from the API calls
test run the recorded testcases and execute assertions
update Update Keploy
Flags:
--debug Run in debug mode
-h, --help help for keploy
-v, --version version for keploy
Use "keploy [command] --help" for more information about a command.
🎉 You have successfully installed Keploy on Linux.
🎬 Start Capturing Test Cases
- Go
- Node.js
- Java
- Python
Record the test cases
keploy record -c "go run main.go"
Run the test cases
keploy test -c "go run main.go" --delay 10
Record the test cases
keploy record -c "npm start"
Run the test cases
keploy test -c "npm start" --delay 10
Record the test cases
keploy record -c "mvn spring-boot:run"
Run the test cases
keploy test -c "mvn spring-boot:run" --delay 10
Record the test cases
keploy record -c "python app.py"
Run the test cases
keploy test -c "python app.py" --delay 10
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Install Keploy with Docker on Linux
- Make sure Docker is installed on Linux.
- Install Keploy
curl --silent -O -L https://keploy.io/install.sh && source install.sh
🎉 You have successfully set up Keploy on Linux using Docker.
🎬 Start Capturing Test Cases
- Docker
- Docker Compose
Record the test cases
keploy record -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 10
Run the test cases
keploy test -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 20
Record the test cases
keploy record -c "docker compose up" --container-name <containerName> --build-delay 100
Run the test cases
keploy test -c "docker compose up" --container-name <containerName> --build-delay 50 --delay 20
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Keploy runs natively on Apple Silicon Macs: no Lima VM, no Docker and no sudo. Natively it understands the HTTP/HTTPS, MySQL and MongoDB calls of Go, Node.js, Python and Java apps; calls to other services — PostgreSQL, Redis, Kafka, gRPC and the like — are captured only as raw bytes and usually don't replay — see Installing Keploy on macOS. For containerized apps or those other dependencies use Docker; on an Intel Mac use Lima, as the macOS CLI is Apple Silicon (arm64) only.
- Native
- Lima
- Docker
Install Keploy
curl --silent -O -L https://keploy.io/install.sh && source install.sh
🎬 Start Capturing Test Cases
- Go
- Node.js
- Java
- Python
Record the test cases
keploy record -c "./app"
Run the test cases
keploy test -c "./app" --delay 10
Record the test cases
keploy record -c "node server.js"
Run the test cases
keploy test -c "node server.js" --delay 10
Record the test cases
keploy record -c "${JAVA_HOME:-$(/usr/libexec/java_home)}/bin/java -jar target/<your-app>.jar"
Run the test cases
keploy test -c "${JAVA_HOME:-$(/usr/libexec/java_home)}/bin/java -jar target/<your-app>.jar" --delay 10
Record the test cases
keploy record -c ".venv/bin/python app.py"
Run the test cases
keploy test -c ".venv/bin/python app.py" --delay 10
On macOS, build first (go build -o app ., mvn package) and start the app itself, not through a launcher such as npm start, mvn or a wrapper script. Use your JDK's own java and a virtualenv built on a Homebrew, uv or pyenv Python, not Apple's /usr/bin/java or /usr/bin/python3. macOS removes Keploy from those processes, and Keploy warns you when that happens.
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Install Keploy with Lima
- Check if Lima is installed. If you already have a Lima instance, make it writable (see step 3) and skip to step 5, using its name in place of
debian-12. - Install Lima
brew install lima
- Create a Debian instance
limactl create --mount-writable template://debian-12
Lima mounts your Mac's home folder read-only by default; --mount-writable lets Keploy write its test files into your project. If you already have an instance, stop it if it's running (limactl stop <name>), then make it writable with limactl edit <name> --mount-writable --start.
- Start the instance
limactl start debian-12
- Enter the Linux shell
limactl shell debian-12
- Install Keploy inside Lima, from the VM's own home directory
cd ~ && curl --silent -O -L https://keploy.io/install.sh && source install.sh
🎉 You have successfully set up Keploy on macOS using Lima.
🎬 Start Capturing Test Cases
- Go
- Node.js
- Java
- Python
Record the test cases
keploy record -c "go run main.go"
Run the test cases
keploy test -c "go run main.go" --delay 10
Record the test cases
keploy record -c "npm start"
Run the test cases
keploy test -c "npm start" --delay 10
Record the test cases
keploy record -c "mvn spring-boot:run"
Run the test cases
keploy test -c "mvn spring-boot:run" --delay 10
Record the test cases
keploy record -c "python app.py"
Run the test cases
keploy test -c "python app.py" --delay 10
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Install Keploy with Docker on macOS
Your application and Keploy's agent run in containers here, but the keploy CLI installed in step 2 — which starts them both — runs on your Mac, and is Apple Silicon (arm64) only. On an Intel Mac use the Lima tab instead.
- Make sure Docker Desktop is running on macOS.
- Install Keploy
curl --silent -O -L https://keploy.io/install.sh && source install.sh
- Create the Docker network your app's container and Keploy share
docker network create keploy-network
🎉 You have successfully set up Keploy on macOS using Docker.
🎬 Start Capturing Test Cases
- Docker
- Docker Compose
Record the test cases
keploy record -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 10
Run the test cases
keploy test -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 20
Record the test cases
keploy record -c "docker compose up" --container-name <containerName> --build-delay 100
Run the test cases
keploy test -c "docker compose up" --container-name <containerName> --build-delay 50 --delay 20
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Keploy runs natively on Windows (x86-64) with no WSL, no Docker and no Administrator — see Installing Keploy on Windows. You can also run it using WSL or Docker; on Windows on ARM, use WSL.
- Native
- WSL
- Docker
Install Keploy
Run this in PowerShell (not as Administrator), then open a new terminal:
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$dir = "$env:USERPROFILE\.keploy\bin"
New-Item -ItemType Directory -Force $dir | Out-Null
Invoke-WebRequest -Uri "https://keploy.io/ent/dl/latest/enterprise_windows_amd64.exe" `
-OutFile "$dir\keploy.exe"
Unblock-File "$dir\keploy.exe"
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$dir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$dir", "User")
}
🎬 Start Capturing Test Cases
- Go
- Node.js
- Java
- Python
Record the test cases
keploy record -c "go run main.go"
Run the test cases
keploy test -c "go run main.go" --delay 10
Record the test cases
keploy record -c "npm start"
Run the test cases
keploy test -c "npm start" --delay 10
Record the test cases
keploy record -c "mvn spring-boot:run"
Run the test cases
keploy test -c "mvn spring-boot:run" --delay 10
Record the test cases
keploy record -c "python app.py"
Run the test cases
keploy test -c "python app.py" --delay 10
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Install Keploy with WSL
- Enable WSL
wsl --install -d <Distribution Name>
👉 We recommend Ubuntu-22.04.
- Install Keploy inside WSL
curl --silent -O -L https://keploy.io/install.sh && source install.sh
🎉 You have successfully set up Keploy on Windows using WSL.
🎬 Start Capturing Test Cases
- Go
- Node.js
- Java
- Python
Record the test cases
keploy record -c "go run main.go"
Run the test cases
keploy test -c "go run main.go" --delay 10
Record the test cases
keploy record -c "npm start"
Run the test cases
keploy test -c "npm start" --delay 10
Record the test cases
keploy record -c "mvn spring-boot:run"
Run the test cases
keploy test -c "mvn spring-boot:run" --delay 10
Record the test cases
keploy record -c "python app.py"
Run the test cases
keploy test -c "python app.py" --delay 10
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Install Keploy with Docker on Windows
- Make sure Docker Desktop is running on Windows.
- Install Keploy with the PowerShell script in the Native tab. The
keployCLI runs on Windows and starts your app's container and Keploy's agent in Docker. - Create the Docker network your app's container and Keploy share
docker network create keploy-network
🎉 You have successfully set up Keploy on Windows using Docker.
🎬 Start Capturing Test Cases
- Docker
- Docker Compose
Record the test cases
keploy record -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 10
Run the test cases
keploy test -c "docker run -p <appPort>:<hostPort> --name <containerName> --network keploy-network --rm <applicationImage>" --containerName "<containerName>" --delay 20
Record the test cases
keploy record -c "docker compose up" --container-name <containerName> --build-delay 100
Run the test cases
keploy test -c "docker compose up" --container-name <containerName> --build-delay 50 --delay 20
📖 What’s Next?
Now, take it further by following the Quickstart Guide and see Keploy in action with your app.
Related
- Keploy Docs Contribution Guide — contribute to the documentation.
- Testing Guide — how Keploy's test bench works.
- Debugger Guide — debug Keploy while developing.
- How Keploy Works? — the internal architecture.