Skip to content

docs(agents): guideline for avoiding test duplication#11546

Open
LukaszRozmej wants to merge 1 commit intomasterfrom
docs/agents-test-duplication
Open

docs(agents): guideline for avoiding test duplication#11546
LukaszRozmej wants to merge 1 commit intomasterfrom
docs/agents-test-duplication

Conversation

@LukaszRozmej
Copy link
Copy Markdown
Member

Changes

  • AGENTS.md "Coding guidelines and style" — new bullet on avoiding code duplication, especially in tests:
    • parameterize with [TestCase(...)] / [TestCaseSource(...)] when tests differ only by inputs/expected values
    • extract helper methods or types (builders, shared static helpers, base fixtures) when only parts of tests are similar
    • cross-link to test-infrastructure.md for the concrete patterns
  • .agents/rules/test-infrastructure.md "Test guidelines" — extend the existing TestCase/TestCaseSource rules with concrete patterns for partial duplication:
    • shared arrange/build → builders (Build.A.Block..., TestItem.*) or private helpers
    • shared assertions → helper methods so each test asserts in one line
    • shared scenarios across files → base fixture, shared static helper, or fixture-level [SetUp]
    • guard against helpers that hide test-relevant behavior
    • note when to prefer [TestCaseSource] over [TestCase] (non-constant data, named scenarios, grows beyond a handful)

Complements PR #11544 which added the comments / XML-doc guidance. Same kind of cross-cutting agent rule, kept in a separate PR for clean review.

Types of changes

  • Documentation update

Testing

Requires testing

  • No

Documentation

Requires documentation update

  • No

Requires explanation in Release Notes

  • No

Add to AGENTS.md "Coding guidelines and style":
- Avoid code duplication, especially in tests
- Parameterize with [TestCase]/[TestCaseSource] when tests differ only by inputs
- Extract helper methods/types when only parts of tests are similar

Extend .agents/rules/test-infrastructure.md "Test guidelines":
- Concrete patterns for partial duplication: helper methods, builders, base fixtures, shared static helpers
- Note when to prefer [TestCaseSource] over [TestCase]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants