← ClaudeAtlas

rest-api-test-generatorlisted

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".
timwukp/agent-skills-best-practice · ★ 3 · API & Backend · score 79
Install: claude install-skill timwukp/agent-skills-best-practice
# REST API Test Generator ## Instructions ### Step 1: API Discovery Ask the user: 1. Which endpoint? (e.g., `POST /api/users`) 2. Framework? (RestAssured, MockMvc) 3. Authentication? (Bearer token, Basic auth, none) 4. Test environment? (Mock server, local, staging) 5. 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: 1. **Success case** (e.g., 201 Created) 2. **Validation error** (e.g., 400 Bad Request) 3. **Business logic error** (e.g., 409 Conflict, 404 Not Found) Use RestAssured template: ```java @Test void shouldCreateUser_whenValidRequest() { given() .contentType(ContentType.JSON) .body(validUserRequest) .when() .post("/api/users") .then() .statusCode(201) .body("id", notNullValue()) .body("email", equalTo("test@example.com")); } ``` **STOP after 3 tests.** Ask the user to run and confirm responses match. ### Step 3: Validation Gate Validation command: ```bash 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 failu