DEV Community

UDDIPTA SINGHA
UDDIPTA SINGHA

Posted on

How I Moved From Manual Testing to AI-Powered API Coverage with Keploy

๐Ÿ“Œ Introduction
As a developer building and maintaining backend APIs, Iโ€™ve always found API testing to be one of the most repetitive and time-consuming tasks. Writing individual test cases, ensuring coverage, and keeping tests updated with every change can be exhausting.

But that changed when I discovered Keploy โ€” an AI-powered testing tool that automatically generates test cases by observing real API traffic.

In this blog, Iโ€™ll share how I used Keploy in my Inventory Manager project, my journey from 0% to 100% API test coverage, and why I think AI will transform how we approach testing.

๐Ÿ› ๏ธ The Problem with Manual API Testing
Before Keploy, testing looked like this:

Manually writing test cases using Jest or Supertest

Creating sample data, setting up mock servers

Writing assertions for every request and response

Updating tests with every API update

Even for a small CRUD app, this could take hours โ€” and often left you with poor coverage or outdated tests.

๐Ÿค– Introducing Keploy
Keploy offers a different approach. Instead of writing test cases manually, it records your real API traffic and auto-generates tests from it โ€” complete with assertions and mocks.

It acts as a proxy, intercepting API requests and responses to turn them into reusable tests that can be run anytime.

๐Ÿ“ฆ Think of it as turning real user behavior into test cases. No code, no boilerplate.

โœ… What I Built: Inventory Manager
For this, I used my own project โ€“ a Node.js + Express app called Inventory Manager, with basic CRUD functionality:

GET /api/items

POST /api/items

PUT /api/items/:id

DELETE /api/items/:id

This project also supports CSV/Excel import, light/dark mode, and a frontend built using vanilla HTML, CSS, and JS.

๐Ÿงช Testing with Keploy: Step-by-Step
1๏ธโƒฃ Install Keploy
On Linux/macOS:

bash
Copy
Edit
curl -sL https://get.keploy.io | bash
On Windows, download the binary from Keploy Releases and add the path to environment variables.

2๏ธโƒฃ Start Recording API Calls
Keploy needs to record your traffic. You can run:

bash
Copy
Edit
keploy record -c "npm start"
Then make API requests using curl, Thunder Client, or your frontend.

Example:

bash
Copy
Edit
curl -X POST http://localhost:5000/api/items \
-H "Content-Type: application/json" \
-d '{"name": "Chair", "quantity": 5}'
Keploy will generate YAML test files under the keploy/tests folder.

3๏ธโƒฃ Run the Tests
Once the traffic is recorded, you can test your API:

bash
Copy
Edit
keploy test
Keploy will replay the captured requests and compare the actual response against the recorded one.

๐Ÿ” CI/CD Integration with GitHub Actions
I also added Keploy into my CI/CD pipeline using GitHub Actions. This means:

Every time I push code

Keploy tests run automatically

Any regression is caught immediately

Here's what I added in .github/workflows/api-tests.yml:

yaml
Copy
Edit

  • name: Run Keploy Tests run: | keploy test --config keploy.yaml โœ… The pipeline now builds, runs tests, and fails on regressions.

๐Ÿ“Š Results & Coverage
In just a few minutes of interacting with my own app:

All CRUD endpoints were covered

Mocks were auto-generated

Test cases were created without writing any code

API regressions (if any) were caught instantly

๐ŸŒŸ Why I Loved Using Keploy
๐Ÿง  No manual test writing

๐Ÿš€ Instant test generation from OpenAPI or real traffic

๐Ÿ“‰ Detects breakage due to changes

โš™๏ธ Seamless CI/CD integration

๐Ÿ“Š Test coverage improved effortlessly

Itโ€™s like having a QA assistant running in the background.

โœจ Final Thoughts
Keploy changed how I think about testing. Instead of spending hours writing tests manually, I now:

Record real traffic

Auto-generate tests

Integrate with CI/CD

Focus on building, not debugging

If you're building REST APIs and want reliable testing without the overhead, give Keploy a try. It feels like the future of API testing.

๐Ÿ“ธ Screenshots & Resources
โœ… Keploy test report screenshot (Add this to your README)

๐Ÿ“˜ My GitHub Repo

๐Ÿงช Keploy Docs

๐Ÿ’ฌ Your Turn
Have you tried AI-powered testing?
Want help setting up Keploy on your own project?

Drop a comment below โ€” I'd love to connect!

Top comments (0)