What the brief requires
The test requirements are spread across the brief. Together they are short.
- All existing tests stay in the suite and still pass.
- At least 4 new pytest tests across your two features.
- Backend test results recorded in verification.md.
- Break Test evidence for at least two tests: at least one important Feature 1 test, and the same loop for Feature 2.
- The full pytest suite and the behavior contract run before your refactor, and the contract again after it.
Meaningful tests
Four is a floor, not a target. Use the “good tests” column of your chosen options as a starting list. A meaningful test checks behavior, not just that the server answered: the right status code and the right body, the unchanged fields after an update, the exact set a filter returns, the empty list with a 200 when nothing matches. Follow your existing fixtures, including the storage reset, so tests do not share state.
- Assert status plus content: ids, fields, flags, the returned set.
- Cover the boundary: due today, a blank value, a missing id.
- Cover the failure: invalid input returns the validation response.
- Cover the regression: omitting the new parameter keeps old behavior.
Read with careModule 2 lists common AI mistakes in generated tests: asserting 200 when the route returns 201 or 204, a test name that does not match its body, calling json() on a 204, and a reset fixture without autouse so tests share state. Read every AI-written test before you trust it.
The Break Test
A green suite tells you the code and the tests agree. It does not tell you the tests would notice if the code were wrong. The Break Test checks that. You take one important passing test, make one small temporary change to the application source that should break the behavior it protects, and run the test again. It should fail, for the reason you expected. Then you restore the source exactly and see it pass again.
- 1PassThe selected test passes on correct source.
- 2Mutate sourceOne small, temporary change. Never the test.
- 3Expected failureFails on the rule it protects, not a syntax error.
- 4RestoreExact restoration, e.g. from the checkpoint.
- 5Pass + cleanPasses again; git shows no leftover change.
Key ideaIf the test does not fail when the behavior is broken, fix the test, not the production code. A test that passes while the behavior is broken is protecting nothing.
What makes the evidence convincing
Record the Break Test as steps, not as a claim. The reviewer should be able to see the passing command, the exact mutation, the failure message, why that failure is about the rule and not a typo, the restoration, the passing re-run, and proof that no temporary change is left behind.
| Step | Record |
|---|---|
| Selected test | Its name, and the behavior it protects. |
| Correct source | The targeted command and its passing result. |
| Temporary mutation | File, function, and the one change made. Test file unchanged. |
| Mutated result | The same command failing, with the assertion message. |
| Why it is semantic | One sentence linking the failure to the rule. |
| Restoration | How the source was restored, then the passing re-run and full suite. |
| Clean state | git diff and git status showing nothing left over. |
The behavior contract
The brief asks for a behavior contract before and after your refactor, but it is a Module 3 idea: a short checklist of observable behaviors, each marked PASS before you refactor and re-checked after. For the midcourse project, extend your Module 3 contract with the new features’ behaviors: the new field round-trips, the filter returns only what it should, the empty state is valid, errors stay visible. Browser items cannot be marked PASS from reading code; they need an observation.
Key takeaways
- Keep every existing test; add at least four meaningful new ones.
- Assert status and content, boundaries, failures and regressions.
- A Break Test mutates source, never the test, and must fail for the semantic reason.
- Restore exactly and prove a clean working tree.
- Run the behavior contract before and after the refactor, with real observations.