/keploy

Test generation for Developers. Generate tests and stubs for your application that actually work!

Primary LanguageGoApache License 2.0Apache-2.0

keploy logo

⚡️ Backend tests faster than unit tests, from user traffic ⚡️

🌟 The must-have tool for developers in the AI-Gen era 🌟

🎤 Introducing Keploy 🐰

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!

Generate Test Case from API call

🐰 Fun fact: Keploy uses itself for testing! Check out our swanky coverage badge: Coverage Status  

🌐 Language Support

From Go's gopher 🐹 to Python's snake 🐍, we support:

Go Java NodeJS Python

🎩 How's the Magic Happen?

Our magical 🧙‍♂️ Keploy proxy captures and replays ALL(CRUD operations, including non-idempotent APIs) of your app's network interactions.

Take a journey to How Keploy Works? to discover the tricks behind the curtain!

Generate Test Case from API call

📘 Get Schooled!

Become a Keploy pro with our Documentation.

Quick Installation

Keploy can be utilized on Linux natively and through WSL on Windows.

One touch install Keploy.

 curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh

Capturing Test cases

To initiate the recording of API calls, execute this command in your terminal where you usually run your app, if you have to set any environment variables do it like you usually do it:

keploy record -c "CMD_TO_RUN_APP"

For instance, if you're using a simple Golang program, the command would resemble:

keploy record -c "go run main.go"

Running Testcases

To run the test cases and generate a test coverage report, use this terminal command where you usually run your app, if you have to set any environment variables do it like you usually do it:

keploy test -c "CMD_TO_RUN_APP" --delay 10

For example, if you're using a Golang framework, the command would be:

keploy test -c "go run main.go" --delay 10

Docker setup

Keploy can be used on Linux & Windows through Docker.

️ Note: MacOS users need to install Colima. Windows users need to install WSL.

Recording Testcases and Data Mocks

Here are a 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 all of the containers on the same network when you're using docker run command (you can add your custom network name using --network flag in docker run command).
  • In your Docker Compose file, every container should run on the same network.
  • Docker_CMD_to_run_user_container refers to the Docker command for launching the application.

To capture test cases, 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 test cases (KTests) and data mocks (KMocks) in YAML format.

Running Testcases

To execute the test cases, 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 as locally in the testReport directory.

🤔 Questions?

Reach out to us. We're here to help!

Slack LinkedIn YouTube Twitter

💖 Let's Build Together!

Whether you're a newbie coder or a wizard 🧙‍♀️, your perspective is golden. Take a peek at our:

📜 Contribution Guidelines

❤️ Code of Conduct

🌟 Features

🚀 Export, maintain, and show off tests and mocks!

Generate Test Case from API call

🤝 Shake hands with popular testing frameworks – Go-Test, JUnit, Py-Test, Jest, and more!

Generate Test Case from API call

🕵️ Detect noise with surgeon-like precision!

Filters noisy fields in API responses like (timestamps, and random values) to ensure high-quality tests.

📊 Say 'Hello' to higher coverage!

Keploy ensures that redundant test cases are not generated.

🐲 The Challenges We Face!

  • 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 them 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

✨ Resources!

🤔 FAQs

🕵️‍️ Why Keploy

⚙️ Installation Guide

📖 Contribution Guide

🌟 Hall of Contributors

contributors

Available Awards

Name Icon Description
Docs Maker docs-icon Awarded for helping in improving Keploy documentation!
Every Bit Counts commit-icon No commit is too small!
Pull Request Hero PR-hero-icon You're a PR hero, rock on!
Closer closer-icon Only closers get coffee!