π The must-have tool for developers in the AI-Gen era π
Keploy is a developer-centric backend testing tool. It makes backend tests with built-in-mocks, faster than unit tests, from user traffic, making it easy-to-use, powerful and extensible. π
Ready for the magic? Here are Keploy's core features:
-
β»οΈ Combined Test Coverage: Merge your Keploy Tests with your fave testing libraries(junit, go-test, py-test, jest) to see a combined test-coverage.
-
π€ EBPF Instrumentation: Keploy uses EBPF like a secret sauce to make integration code-less, language agnostic, and oh-so-lightweight.
-
π CI/CD Integration: Run tests with mocks anywhere you likeβlocally on the CLI, in your CI pipeline, or even across a Kubernetes cluster. It's testing wherever you want it!
-
π Multi-Purpose Mocks: Use 'em in existing tests, as server tests, or just to impress your friends!
-
π½οΈ Record-Replay Complex Flows: Keploy can record and replay complex, distributed API flows as mocks and stubs. It's like having a time machine for your testsβsaving you tons of time!
π° Fun fact: Keploy uses itself for testing! Check out our swanky coverage badge: Β
From Go's gopher πΉ to Python's snake π, we support:
Our magical π§ββοΈ Keploy proxy captures and replays ALL(CRUD operations, including non-idempotent APIs) your app's network interactions.
Take a journey to How Keploy Works? to discover the tricks behind the curtain!
Become a Keploy pro with our Documentation.
Keploy can be utilized on Linux natively and through WSL on Windows.
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
ARM Architecture
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_arm64.tar.gz" | tar xz -C /tmp
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
To initiate the recording of API calls, execute this command in your terminal:
sudo -E keploy record -c "CMD_TO_RUN_APP"
For instance, if you're using a simple Golang program, the command would resemble:
sudo -E keploy record -c "go run main.go"
To run the testcases and generate a test coverage report, use this terminal command:
sudo -E keploy test -c "CMD_TO_RUN_APP" --delay 10
For example, if you're using a Golang framework, the command would be:
sudo -E keploy test -c "go run main.go" --delay 10
Keploy can be used on Linux & Windows through Docker.
οΈ Note: MacOS users need to install Colima. Windows users need to install WSL.
Let's create an alias for Keploy:
alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/keploy/keploy'
Here are few points to consider before recording!
- If you're running via docker compose, ensure to include the
<CONTAINER_NAME>
under your application service in the docker-compose.yaml file like this. - You must run the containers on a network, if not, ensure all your containers are on same network with external property true - like this. Replace the network name (
--network
flag) to your custom network if you changed it above, like network in given example. Docker_CMD_to_run_user_container
refers to the Docker command for launching the application.
Utilize the keploy alias we created to capture testcases. Execute the following command within your application's root directory.
keploy record -c "Docker_CMD_to_run_user_container --network <network_name>" --containerName "<container_name>"
Perform API calls using tools like Hoppscotch, Postman, or cURL commands.
Keploy will capture the API calls you've conducted, generating test suites comprising testcases (KTests) and data mocks (KMocks) in YAML
format.
Now, use the keployV2 Alias we created to execute the testcases. Follow these steps in the root directory of your application.
When using docker-compose to start the application, it's important to ensure that the --containerName
parameter matches the container name in your docker-compose.yaml
file.
keploy test -c "Docker_CMD_to_run_user_container --network <network_name>" --containerName "<container_name>" --delay 20
VoilΓ ! π§π»βπ» We have the tests with data mocks running! π°π
You'll be able to see the test-cases that ran with the results report on the console as well locally in the testReport
directory.
Reach out to us. We're here to help!
Whether you're a newbie coder or a wizard π§ββοΈ, your perspective is golden. Take a peek at our:
β€οΈ Code of Conduct
Filters noisy fields in API responses like (timestamps, random values) to ensure high quality tests.
Keploy ensures that redundant testcases are not generated.
- Unit Testing: While Keploy is designed to run alongside unit testing frameworks (Go test, JUnit..) and can add to the overall code coverage, it still generates E2E tests.
- Production Lands: Keploy is currently focused on generating tests for developers. These tests can be captured from any environment, but we have not tested it on high volume production environments. This would need robust deduplication to avoid too many redundant tests being captured. We do have ideas on building a robust deduplication system #27
π€ FAQs
π΅οΈβοΈ Why Keploy
βοΈ Installation Guide
π Contribution Guide