11 / 89 · 04 API & Contract Testing with AI · AI-Generated API Test Examples← prev⊞ allnext →☰ Read as one page
2.4Common Improvements Needed After Generation
| Issue | How to Fix |
|---|---|
| BASE_URL hardcoded | Move to environment variable or pytest fixture |
get_test_token undefined |
Create a conftest.py fixture or helper module |
| Missing timeout on HTTP calls | Add timeout=10.0 to all httpx calls |
| No error message assertions | Add assert "name" in response.json()["detail"] for 400 responses |
| Missing Content-Type header | Add "Content-Type": "application/json" to headers |
| No test for PATCH vs PUT semantics | If both exist, test that PUT replaces and PATCH merges |