12.3The Curation Workflow
When you choose "Generate + Curate," follow this five-step process:
Step 1: GENERATE (5 minutes)
Feed context (spec, existing tests, constraints) and request specific coverage targets.
claude "Read the OpenAPI spec at docs/api.yaml for the /products endpoint.
Generate 30 tests using pytest+httpx covering:
- All documented status codes
- Boundary values for price (min: 0.01, max: 99999.99)
- All enum values for category
- Auth scenarios (valid, expired, missing, wrong role)
Save to tests/test_products_generated.py"
Result: 20-40 tests generated in under 5 minutes.
Step 2: TRIAGE (5 minutes)
Scan test names. Do they make sense? Look for hallucinated APIs or nonsense assertions. Delete obviously wrong tests immediately.
# Quick triage checklist:
# [ ] Test names are descriptive and follow convention
# [ ] No duplicate scenarios (different names, same test)
# [ ] All referenced fixtures exist
# [ ] All API endpoints are real (grep the route file)
# Typical triage result: delete 10-20% of generated tests
Step 3: VALIDATE (15 minutes)
Run the test suite. Fix import errors and missing fixtures. Identify tests that pass but test nothing useful (tautologies).
# Run and observe
pytest tests/test_products_generated.py -v --tb=short
# Common fixes needed:
# - Import paths (AI guesses, not always correctly)
# - Fixture names (AI may use generic names like "client" instead of your "api_client")
# - Base URL configuration
# - Auth helper function signatures
Step 4: STRENGTHEN (10 minutes)
Add missing negative cases. Harden brittle assertions. Add parametrize decorators for data-driven tests.
# BEFORE: AI generated separate tests for each enum value
def test_category_electronics(self): ...
def test_category_clothing(self): ...
def test_category_food(self): ...
# AFTER: Consolidate into parametrized test
@pytest.mark.parametrize("category", ["electronics", "clothing", "food", "other"])
def test_valid_category_accepted(self, client, auth, category):
response = client.post("/api/products", json={
"name": "Test", "price": 10.00, "category": category
}, headers=auth)
assert response.status_code == 201
assert response.json()["category"] == category
Step 5: INTEGRATE (5 minutes)
Ensure consistent naming with existing suite. Move into proper test directories. Add to CI configuration.
# Rename to follow convention
mv tests/test_products_generated.py tests/test_products_api.py
# Verify it runs with the full suite
pytest tests/ -v --tb=short
# Verify coverage did not decrease
pytest tests/ --cov=app --cov-report=term-missing
Total time: ~40 minutes for 25-30 production-quality tests. Without AI: ~5-6 hours for the same coverage.