Rest api test generator
Skill timwukp/agent-skills-best-practice/skills/skills/rest-api-test-generator
35 portable agent skills (Agent Skills spec) for Kiro & Claude Code: Scrum DevSecOps roles, PCI-DSS/MAS TRM compliance, AWS Well-Architected reviews — each with evals and a 4-layer tested methodology
npx -y skills add timwukp/agent-skills-best-practice --skill rest-api-test-generatorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Generates REST API tests using RestAssured or MockMvc with loop prevention and incremental validation. Triggers on: "test API endpoints", "generate API tests", "test REST API", "create integration tests".
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
4.0 KB, as published. Nobody here has run it
REST API Test Generator
Instructions
Step 1: API Discovery
Ask the user:
- Which endpoint? (e.g.,
POST /api/users) - Framework? (RestAssured, MockMvc)
- Authentication? (Bearer token, Basic auth, none)
- Test environment? (Mock server, local, staging)
- Request body example and expected response codes
Provide an upfront estimate: 15-20 credits per test scenario.
Step 2: Generate 3 Scenarios Per Batch
Generate exactly 3 test scenarios:
- Success case (e.g., 201 Created)
- Validation error (e.g., 400 Bad Request)
- Business logic error (e.g., 409 Conflict, 404 Not Found)
Use RestAssured template:
@Test
void shouldCreateUser_whenValidRequest() {
given()
.contentType(ContentType.JSON)
.body(validUserRequest)
.when()
.post("/api/users")
.then()
.statusCode(201)
.body("id", notNullValue())
.body("email", equalTo("[email protected]"));
}
STOP after 3 tests. Ask the user to run and confirm responses match.
Step 3: Validation Gate
Validation command:
python scripts/validate_api_tests.py <TestClassName> --base-url http://localhost:8080
Do NOT generate more tests until the user confirms the current batch passes.
Step 4: Fix or Skip (Max 2 Attempts)
If tests fail:
- Attempt 1: Check request/response format, Content-Type, auth token
- Attempt 2: Adjust assertions (nested paths, flexible matchers like
hasKey,anyOf) - After 2 failures: Skip and document expected vs. actual behavior
This usually indicates an API contract mismatch or environment issue -- not something more iterations will fix.
Step 5: Iterate or Finish
After a passing batch, offer:
- Auth tests (401, 403)
- Additional validation scenarios
- Other endpoints
- Stop and produce summary
Step 6: Summary Report
Endpoint: POST /api/users
Tests Generated: N
Status Codes Covered: 201, 400, 401, 409
Skipped: N (with reasons)
Measuring Credit Cost for Your Endpoints
Credit costs vary by Kiro account, model, and endpoint complexity. To get accurate numbers for your environment, follow these steps.
1. Establish your baseline (one-time)
Run the built-in benchmark with a simple GET endpoint:
python track_credits.py benchmark api-simple
This measures the cheapest possible API test on your account (e.g., 0.077 credits/test).
2. Estimate before running on your endpoint
Real API tests get more expensive with nested JSON, auth, and more assertions:
| What makes API tests cost more | How it's scored |
|---|---|
| Deeper request/response JSON | +1 for each nesting level |
| More response assertions | +1 for every 3 assertions |
| Authentication setup | +1 for Bearer, +2 for OAuth flows |
| More status codes to test | +1 for every 3 codes |
python track_credits.py estimate \
--type api \
--nesting-levels 2 \
--branches 4 \
--annotations 3 \
--tests 3
3. Measure actual cost after running
# Note credit balance before and after, then record:
python track_credits.py add "UsersAPI-POST-3tests" <before> <after> "3 RestAssured tests, auth"
Your measurements improve future estimates automatically.
See ../../../skills-workshop/credit-estimation/CREDIT-ESTIMATION-GUIDE.md for the full guide.
References
references/examples/UserApiTest.java- Complete RestAssured example../../../skills-workshop/credit-estimation/CREDIT-ESTIMATION-GUIDE.md- Credit measurement methodology- RestAssured Documentation
- Spring MockMvc Guide