Skip to content

Document test project conventions - #68984

Merged
javiercn merged 3 commits into
mainfrom
javiercn-test-project-conventions
Sep 2, 2026
Merged

javiercn merged 3 commits into
mainfrom
javiercn-test-project-conventions

Conversation

@javiercn

@javiercn javiercn commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Description

Adds concise repository-wide test organization conventions to .github/copilot-instructions.md, with a reminder to follow more specific guidance from an area's AGENTS.md when present.

  • Documents unit-test project names, established test categories, test assets, file/class mappings, public test classes, method naming, and helper placement.
  • Adds MVC-specific guidance for its singular .Test naming, functional and integration projects, WebSites, and shared test infrastructure.
  • Clarifies that Components E2E tests use the existing xUnit and Selenium suite. Microsoft.AspNetCore.Components.Testing is not selected unless a request explicitly targets it.

Analysis

I inferred these conventions from the central build logic and a repository-wide inventory:

  • Directory.Build.props derives test-project behavior from project names, while 129 product projects contain test-named InternalsVisibleTo entries. Exact test assembly names are therefore load-bearing rather than cosmetic.
  • Of 626 projects under src, 182 match the repository's name-based test-project convention: 114 ordinary .Tests, 33 .Test, 21 functional, 5 explicitly named E2E, 2 integration, and 7 other specialized Tests suffixes.
  • Of 2,425 parsed test source files, 2,249 had a filename matching the primary test class and 2,423 used a public primary test class.
  • Both FooTest and FooTests are common, and about 28% of 25,606 parsed test methods omit underscores. The guidance preserves neighboring singular/plural and method-name styles instead of selecting one globally.
  • Only two projects use .IntegrationTests, so that category is documented only in the MVC area where it is established.
  • Only 57 files split a partial test class as <Class>.<Concern>.cs, and explicit Arrange/Act/Assert comments appeared in 1,194 files. Neither pattern is promoted as a repository-wide convention.
  • A separate class-name probe found only about 60% of test classes map directly to a production type, so the guidance also permits behavior- and scenario-oriented test classes.

The source counts are approximate: the scan selected C# files under test/tests containing recognized test attributes and a top-level test class, while excluding test assets, websites, snapshots, and build outputs.

Validation

  • git diff --check
  • Reviewed the guidance against current origin/main, central test classification, representative test projects, and existing Components E2E infrastructure.

No product tests were run because this PR changes contributor guidance only.

Risks / follow-ups

Risk is limited to guidance being applied too broadly. Repository-wide rules preserve established names and categories, and area-specific exceptions remain in scoped AGENTS.md files.

@javiercn
javiercn marked this pull request as ready for review September 2, 2026 12:32
Copilot AI lite review requested due to automatic review settings September 2, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

.github/copilot-instructions.md still states “We use xUnit SDK v3 for tests” in a repo-wide way despite documented MSTest/Playwright test stacks, which is likely to misdirect contributors.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds repository-wide contributor guidance for test project organization/naming and then scopes area-specific exceptions/details to Components and MVC guidance files, wiring these docs into GitHub Copilot’s instruction entry points.

Changes:

  • Add a root-level AGENTS.md documenting repo-wide test organization conventions (naming, categories, test assets, file/class mapping, helper placement).
  • Add MVC-scoped contributor guidance + a corresponding .github/instructions entry to apply it to src/Mvc/**.
  • Update Components/Testing/ProjectTemplates guidance to defer to the new repository-level AGENTS.md and clarify distinct E2E stacks in Components.
File summaries
File Description
AGENTS.md Introduces repository-wide test organization/naming guidance meant to be the default baseline.
.github/copilot-instructions.md Links Copilot’s “Testing” section to the new root AGENTS.md.
.github/instructions/mvc.instructions.md Adds scoped Copilot instructions so MVC guidance is applied to src/Mvc/**.
src/Mvc/AGENTS.md Adds MVC-specific conventions (notably functional/integration test project placement and shared helper guidance).
src/Components/AGENTS.md Clarifies Components’ multiple E2E stacks and points Playwright/MSTest consumers to src/Components/Testing/AGENTS.md.
src/Components/Testing/AGENTS.md Documents the MSTest/Microsoft.Testing.Platform + Playwright E2E test layout and conventions for this stack.
src/ProjectTemplates/AGENTS.md Adds a pointer to the repository-level AGENTS.md as the baseline, preserving local specifics.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/copilot-instructions.md Resolved
Keep Components E2E guidance on the established xUnit and Selenium suite unless Components.Testing is explicitly requested.

Co-authored-by: Copilot App <[email protected]>
@javiercn
javiercn marked this pull request as draft September 2, 2026 12:39
@javiercn
javiercn marked this pull request as ready for review September 2, 2026 14:51
Comment thread .github/copilot-instructions.md Resolved
@javiercn
javiercn enabled auto-merge (squash) September 2, 2026 16:41
@javiercn
javiercn merged commit 4e4753c into main Sep 2, 2026
16 checks passed
@javiercn
javiercn deleted the javiercn-test-project-conventions branch September 2, 2026 16:49
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 3, 2026
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.

3 participants