Awesome Reviewers

Reviewer · Testing

Tests must verify real behavior

A test that passes without actually exercising or confirming the behavior it claims to guard is worse than no test: it gives false confidence and lets regressions slip through silently. When writing or reviewing tests, check for these failure modes:

Instruction

A test that passes without actually exercising or confirming the behavior it claims to guard is worse than no test: it gives false confidence and lets regressions slip through silently. When writing or reviewing tests, check for these failure modes:

  1. Process-global/shared state leakage. Module-level caches (e.g. a _warned set) must be reset in the test itself or a fixture, otherwise results depend on test execution order.
    def test_warns_once_skips_excluded_and_raises_when_strict(self):
     from swarms.structs import serialization as _serialization
     _serialization._warned.clear()
     agent = Agent.__new__(Agent)
     ...
    

    Run the same test twice in one process (or in a different order) as a sanity check.

  2. Vacuous or over-permissive assertions. Loops/comprehensions that iterate over possibly-empty collections assert nothing if the collection is empty — assert non-emptiness explicitly (assert call["messages"], f"{call['agent']} got no turns"). Similarly, prefer precise matchers over loose ones: text.startswith(worker) and ": " in text would wrongly accept "W1 said something: unrelated"; pin the exact contract instead, e.g. re.match(rf"^{worker}(?: \(layer \d+/\d+\))?: ", text). When possible assert on actual content, not just structure/type (assert any("A-out" in text for text in contents) rather than only checking that messages is non-empty and typed).

  3. Synthetic setup that bypasses the real code path. Building an object with __new__ and a hand-crafted __dict__, or stubbing a method mid-flow, can validate helper logic but will not catch a regression in the real construction path (e.g. Agent.__init__ reintroducing a dropped attribute). When a change claims “a default/real object now behaves correctly,” add a companion test that builds the real object and asserts the end-to-end claim:
    def test_default_agent_has_no_placeholders():
     agent = Agent(agent_name="placeholder-free", model_name="gpt-4o-mini")
     assert not any(
         str(v).startswith("<Non-serializable") for v in agent.to_dict().values()
     )
    
  4. Fragile or unrealistic fixtures. Avoid nonexistent model names (gpt-5.4) or constructing real heavy objects (e.g. a real Agent) when a lightweight fake with the needed attributes/methods would do; this keeps tests honest about what they exercise and resilient to unrelated validation changes or missing credentials in CI. Guard list-indexing on potentially empty results ([-1] on a filtered list) with a clear fallback/assertion so failures are readable instead of raising an opaque IndexError.

  5. Confirm tests are actually collected and run. New test_* functions using pytest fixtures (e.g. tmp_path) appended to a file whose own __main__ block calls a hand-rolled run_all_tests() runner will silently never execute if CI invokes the file as a script. Verify CI collects the file via pytest, or wire new tests into the existing runner.

  6. Keep contract tests next to the code they test. If a shared helper (e.g. tool_call_arguments in swarms/utils/str_to_dict.py) has multiple callers, its core contract tests belong in that module’s own test file so they survive refactors of any one consumer; consumer-specific integration tests can live alongside the consumer.

Applying these checks turns “it passed” into “it would have failed if the bug were still there,” which is the actual bar for a useful test.</description> </invoke>