Skip to content

Agent test guidance: stop requesting low-value tests - #15653

Draft
JanProvaznik wants to merge 3 commits into
mainfrom
janprovaznik-reviewer-test-guidance
Draft

JanProvaznik wants to merge 3 commits into
mainfrom
janprovaznik-reviewer-test-guidance

Conversation

@JanProvaznik

@JanProvaznik JanProvaznik commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Related issue(s): none (triggered by review on #15649)

Context

On #15649 the expert reviewer marked a missing test as MAJOR and pushed for a reflection test asserting that Copy's cached strings are static readonly and non-empty. The race it fixes can't be reproduced reliably. Maintainers have pushed back on bot-requested tests like this many times (table below), but our guidance still says "every behavioral change needs a test" and the reviewer template asks for a proof-of-concept [Fact].

Changes Made

  • One canonical section: a new ## What to test section in .github/instructions/tests.instructions.md.
    • A good test goes through a real entry point, fails without the change on at least one target OS/TFM (refactoring characterization tests excepted), and is deterministic and cheap. Cross-OS contracts count as high-value.
    • The amount of testing should match the risk.
    • Don't write or request: reflection/structure tests, tests that restate constants or defaults, tests of external behavior, or nondeterministic race tests. A stress test is fine only if it reliably fails without the fix.
    • If no meaningful deterministic test exists, put root-cause reasoning and a repro in the PR description instead.
  • expert-reviewer.agent.md:
    • Principle 6 is now "Tests Must Earn Their CI Time".
    • Dimension 4 points to the canonical section, which is pasted verbatim into its sub-agent prompt. It flags a missing test only for non-trivial changes (not defensive guards or tiny string/localization fixes) and only when a realistic deterministic test can be named. It flags low-value tests for deletion, and asks for reasoning or a repro in the PR description only when they are missing, at most MODERATE.
    • Removed the duplicate test-naming rule from dimension 4 (dimension 14 already covers it) and the duplicate "repro as test" check from dimension 22.
    • The proof-of-concept is now evidence for a finding, not a test the PR must add. The [Fact] stub is gone from the comment template.
  • AGENTS.md:
    • The 30-line Running Tests section is now a short paragraph (full suite reserved for broad engine/framework/shared changes) linking the running-unit-tests skill and the "What to test" section.
    • Added one sentence to Code Review Instructions: don't write or request reflection/structure tests, tests restating constants/defaults, or race tests; ask for reasoning and any repro in the PR description only if missing. .github/copilot-instructions.md is a symlink to AGENTS.md, so this reaches Copilot code review even on PRs that don't touch test files (like Fix Copy task ArgumentNullException from racy static resource-string initialization under -mt #15649, which changed only src/Tasks/Copy.cs).
  • Fixed applyTo in tests.instructions.md: it was src/*.Tests/**/*.cs, which matched only 26 files (TaskAnalyzer.Tests, MSBuild.EndToEnd.Tests) and none of the *.UnitTests projects. It is now src/*Tests/**/*.cs,src/UnitTests.Shared/**/*.cs,src/Shared/UnitTests/**/*.cs, which matches 736 files across every test project.
  • running-unit-tests skill: dropped the Quick reference table (every row is already covered in the skill body: direct test exe, -c Release validation, TRX), fixed a -- bullet typo, and linked "What to test".

Line count (raw lines)

File Before After
expert-reviewer.agent.md 690 683
tests.instructions.md 82 86
running-unit-tests/SKILL.md 137 126
AGENTS.md 261 240
Total 1170 1135

The diff adds 38 lines and removes 73.

Evidence behind each principle (17 cases). These are maintainer replies from roughly the last 15 months, mostly to Copilot or Expert Code Review comments.

Principle PR Quote
No reflection/structure tests #15649 "regression test was removed, because it was reflectionslop"
#15649 "strongly disagree" (reply to the bot proposing the IsInitOnly reflection test)
#13023 "tests depend on reflection to verify the state of a variable. That's fragile… better to verify the matrix via end-to-end tests"
Must fail without the change / no tautologies #13854 "The NodeId assertion is a tautology even if the path were hit."
#13256 "this is a trivial test that is useless - remove it"
#13588 "I don't love using the same reflection API as the product code to establish the baseline"
#13661 "test deleted" (the bot had noted it passes without the feature)
No nondeterministic race tests #13422 "This unit test is highly unreliable and not managing to hit the race."
#13615 "a concurrency test is not justified for an attribute-only migration"
Match the risk #15089 "I don't think this warrants a regression test… primarily a defensive safety measure."
#15227 "I disagree that this requires a Korean-only regression test. This is a tiny invariant change"
#15326 "I don't think we need much of a regression test for it. I think it could be nothing"
#13256 "remove this test, we won't be loading from exited processes"
No redundant tests #12662 "This test feels redundant with other task tests, does it add something?"
#13023 "this test can be removed. It's already covered by the test below with the Theory."
#15402 "nonsensical test"
Respect CI time (CI-matrix scope) #15289 "are we willing to double test times for this goal?" (doubling the CI test matrix)

Counter-cases kept in the guidance (listed as "high-value examples" or as rules that stay):

Kept PR Quote
Error paths #12914 "Can you add a test case for that codepath please?"
Cross-OS behavior contract #14708 "it validates that both casings worth on all supported OSes. That's what we want!"
Strong assertions #15041 ">= 0 is too weak to catch the failure mode the feature exists to prevent."
State leaks across node reuse #14588 "we need a test that there is no leak if we reuse msbuild processes…"
Serialization round-trip #14356 "Could we add a node-packet round-trip test for this event?"
ChangeWave opt-out #13319 "the other 3 have no opt-out coverage"

Testing

Guidance-only change; no product code touched.

  • skill-validator check --skills .github/skills --allow-repo-traversal (dotnet/skills nightly, win-x64): ✅ all 17 skills pass. The only warnings were already there before this change.
  • skill-validator check --agents .github/agents: ✅ 1 agent passes.

Add a canonical 'What to test' section to tests.instructions.md and point the
expert reviewer, AGENTS.md and running-unit-tests skill at it instead of
duplicating test guidance. Reviewers must no longer request reflection/structure
tests or nondeterministic race tests; they ask for PR-description evidence when
no meaningful deterministic test exists.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Skill Validator Results

✅ All checks passed

Scope Checked
Skills 1
Agents 1
Total 2
Severity Count
--- ---:
❌ Errors 0
⚠️ Warnings 0
ℹ️ Advisories 0

Summary

Level Finding
ℹ️ Found 1 skill(s)
ℹ️ [running-unit-tests] 📊 running-unit-tests: 2,208 BPE tokens [chars/4: 2,171] (detailed ✓), 9 sections, 6 code blocks
ℹ️ ✅ All checks passed (1 skill(s))
ℹ️ Found 1 agent(s)
ℹ️ Validated 1 agent(s)
ℹ️ ✅ All checks passed (1 agent(s))
Full validator output ```text Found 1 skill(s) [running-unit-tests] 📊 running-unit-tests: 2,208 BPE tokens [chars/4: 2,171] (detailed ✓), 9 sections, 6 code blocks ✅ All checks passed (1 skill(s)) Found 1 agent(s) Validated 1 agent(s) ✅ All checks passed (1 agent(s)) ```

JanProvaznik and others added 2 commits November 23, 2026 17:40
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…tests

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant