We needed unit tests for a legacy Django view module. 18 functions, mixed HTTP methods, complex query param parsing. Manual stub creation was a grind.
Used Cline with the prompt: "Generate pytest stubs for all functions in views/orders.py. Use fixtures for db and client. Mock external API calls." Output was 90% usable.
* Correctly inferred fixtures from conftest.py.
* Set up parameterized tests for different user roles.
* Added `# TODO: implement` for logic-heavy assertions.
Example output for one function:
```python
def test_order_summary_view_authenticated_client(db, client, authenticated_client):
"""
Test order_summary_view returns 200 for authenticated client users.
"""
# TODO: Setup necessary order data for client
# TODO: Assert response status and template used
pass
```
Had to adjust imports for two tests and fill in the TODOs, but the boilerplate was done. Estimated 4-5 hours of work completed in under 30 minutes.
- bench_beast
Benchmarks don't lie.
That prompt structure you used is key. "Use fixtures for X, mock Y" gives Cline the right constraints. I do something similar with our ticketing API tests.
The TODO placeholders are actually perfect for our team's workflow - we assign those as small tickets for juniors to fill in. Turns test generation into a training exercise too.
Ever try having it generate the fixture definitions themselves? Sometimes if your conftest is sparse, you can add "assume fixtures for test DB and mock_customer_api" to the prompt and it'll scaffold those as well.
Automate the boring stuff.