Skip to content

Bugfix workflow: Guide agent to use modern testing patterns #59

@kami619

Description

@kami619

Problem

The agent defaulted to older, more fragile testing patterns:

  • Used tuple indexing for mock arguments (call_args[0][0]) instead of the more readable and robust .args attribute
  • Used capsys to capture output instead of utilizing Click's native CliRunner which was already present in the test suite fixtures

These patterns are more fragile and harder to maintain than modern alternatives.

Impact

  • Tests are more brittle (tuple indexing can break easily)
  • Missed opportunity to use existing test infrastructure (CliRunner fixture)
  • Required additional iteration to fix fragile patterns after review

Context

This issue was identified during the bugfix session for ambient-code/agentready#306 addressing ambient-code/agentready#302.

It took a secondary review to identify and request fixes for these patterns.

Recommended Solution

The bugfix workflow's /test phase should:

  • Instruct the agent to examine existing test patterns in the codebase FIRST
  • Add guidance to prefer modern testing APIs (e.g., call_args.args[0] over call_args[0][0])
  • Explicitly mention checking for existing test fixtures/helpers (like CliRunner)
  • Include a review step: "Do the new tests match the style and patterns of existing tests?"

Consider adding a "Test Pattern Review" section that prompts the agent to:

  • Identify what testing frameworks/patterns are already in use
  • Use consistent patterns with the existing test suite
  • Prefer built-in test utilities over generic ones (e.g., CliRunner vs. capsys for Click apps)

Reference

From PR comment: #42 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions