Reviewer · Testing
Assert the actual regression
A test must fail when the behavior it claims to protect breaks, not just pass when the happy path runs end-to-end. Several review rounds found tests that looked correct but could pass vacuously or for the wrong reason:
A test must fail when the behavior it claims to protect breaks, not just pass when the happy path runs end-to-end. Several review rounds found tests that looked correct but could pass vacuously or for the wrong reason:
- Looping over a collection without first asserting it is non-empty lets a regression that drops all items pass silently (
for m in call["messages"]: ...withmessages == []). Add a guard before the loop, e.g.assert call["messages"], f"{call['agent']} got no turns". - Checking shape/structure (roles are typed, a field is non-empty) without checking the distinguishing content misses the real bug. A round-robin test that only asserted “messages exist and roles are user/assistant” kept passing while the newest turn was silently dropped; the fix was asserting the actual content made it into a turn:
assert any("A-out" in text for text in contents). - A test built only from a hand-constructed/synthetic object (e.g.
Agent.__new__(Agent)with a manually populated__dict__) exercises the helper logic but never the real code path the fix is meant to protect (e.g.Agent.__init__populatingskills,tool_struct, etc.). Pair synthetic unit tests with at least one test that goes through the real constructor/entry point and asserts the end-to-end claim (e.g. “a defaultAgent(...)has no<Non-serializable>placeholders”). - A new test only covers the code path that didn’t change, leaving the actually-changed path (e.g.
stream=Truecombined withimgs) unverified. - A test asserts final output but not the mechanism the change introduced (e.g. it checks the final answer is correct but never asserts
output_type == "final"was actually set on the sub-agents), so an unrelated refactor can break the mechanism without failing CI.
When writing or reviewing a test, ask: “if the fix were reverted, would this test actually fail, and would it fail for the reason I think it tests?” If the answer is unclear, add an explicit assertion on the specific value/state that the change is supposed to guarantee, and include a case that exercises the real (non-mocked) code path in addition to any lightweight/synthetic version.