Skip to content

Split TestMethodRunner.cs into focused partial-class files#9729

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/split-testmethodrunner
Jul 8, 2026
Merged

Split TestMethodRunner.cs into focused partial-class files#9729
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/split-testmethodrunner

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Overview

Fixes #9711.

TestMethodRunner.cs had grown to 591 lines and was the only class in src/Adapter/MSTestAdapter.PlatformServices/Execution/ not following the ClassName.Responsibility.cs partial-class split pattern used by its neighbors (TestMethodInfo, TestExecutionManager, TypeCache, TestClassInfo, UnitTestRunner).

Changes

Split into four focused partial-class files:

File Lines Responsibility
TestMethodRunner.cs 266 Fields, constructor, ExecuteAsync, RunTestMethodAsync, IsDataDrivenTest, GetAggregateOutcome — entry points & routing
TestMethodRunner.DataSource.cs 177 DataSourceAttribute-based data-driven tests
TestMethodRunner.DataRow.cs 107 Folded / DynamicData-style (ITestDataSource) data-driven tests
TestMethodRunner.Execution.cs 89 Core single-test execution (ExecuteTestAsync, UpdateResultsWithParentInfo)

This is a pure structural refactor — no logic changes. Method bodies were moved verbatim; the class is marked partial; usings were trimmed per-file.

GetAggregateOutcome was kept in the entry-point file since it's used by the routing logic in RunTestMethodAsync.

Acceptance criteria

  • Split into 4 partial-class files following the ClassName.Responsibility.cs convention
  • Each new file is under 300 lines
  • Build succeeds (0 warnings, 0 errors across all target frameworks)
  • All 898 MSTestAdapter.PlatformServices.UnitTests pass
  • No behavioral changes — pure structural refactor

Splits the 591-line TestMethodRunner.cs into four partial-class files
following the ClassName.Responsibility.cs convention already used by
neighboring classes in the Execution/ folder:

- TestMethodRunner.cs: entry points and routing (ExecuteAsync,
  RunTestMethodAsync, IsDataDrivenTest, GetAggregateOutcome)
- TestMethodRunner.DataSource.cs: DataSourceAttribute-based tests
- TestMethodRunner.DataRow.cs: folded / DynamicData-style tests
- TestMethodRunner.Execution.cs: core single-test execution

Pure structural refactor with no behavioral changes.

Fixes #9711

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 11:07

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.

Pull request overview

Refactors TestMethodRunner in MSTestAdapter.PlatformServices to match the existing ClassName.Responsibility.cs partial-class organization used by other classes in Execution/, improving navigability without changing behavior.

Changes:

  • Converted TestMethodRunner to a partial type and retained entry-point/routing logic in TestMethodRunner.cs.
  • Extracted data-driven execution paths into dedicated partial files (.DataSource.cs and .DataRow.cs).
  • Moved core single-test execution helpers into TestMethodRunner.Execution.cs.
Show a summary per file
File Description
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs Marks the type partial and keeps the primary entry points/routing plus aggregate outcome logic.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataSource.cs Contains DataSourceAttribute-based data-driven execution logic.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.DataRow.cs Contains folded / ITestDataSource (DynamicData-style) execution logic.
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.Execution.cs Contains core single-test execution (ExecuteTestAsync) and result parent/execution id updates.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Low

@Evangelink
Evangelink enabled auto-merge (squash) July 8, 2026 11:14
@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jul 8, 2026

@github-actions github-actions Bot 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.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review Summary

Clean structural refactor — no issues found. All 22 review dimensions assessed.

Verification

Check Result
All original methods accounted for ✅ 11/11 methods preserved with identical signatures
File naming convention ✅ Follows established ClassName.Responsibility.cs pattern (matches TestMethodInfo, TestExecutionManager, TypeCache, etc.)
using directives per file ✅ Properly trimmed — each partial imports only what it needs
Removed using from main file Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices correctly removed — no longer directly referenced
partial keyword ✅ Applied to class declaration in all 4 files
CI build (Linux Release) ✅ Passed

Dimension Assessment

# Dimension Verdict
1 Algorithmic Correctness N/A — no logic changes
2 Threading & Concurrency N/A — ConfigureAwait(false) patterns preserved verbatim
3 Security & IPC N/A
4 Public API N/A — class is internal sealed
5 Performance N/A — zero runtime impact
6 Cross-TFM N/A — no TFM-specific changes
7 Resource & IDisposable N/A — dispose patterns preserved
8 Defensive Coding N/A
9 Localization N/A
10 Test Isolation N/A — no test files
11 Assertion Quality N/A
12 Flakiness N/A
13 Test Completeness N/A
14 Data-Driven Coverage N/A
15 Code Structure LGTM — this PR improves structure
16 Naming LGTM — consistent with neighbors
17 Documentation LGTM — XML doc summaries on each partial describe responsibility
18 Analyzer Quality N/A
19 IPC Wire N/A
20 Build Infrastructure N/A
21 Scope & PR Discipline LGTM — single concern, well-scoped
22 PowerShell N/A

No blocking or major issues. Well-executed refactor that brings TestMethodRunner in line with the established partial-class conventions in its directory.

@Evangelink
Evangelink merged commit 0b9248a into main Jul 8, 2026
35 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/split-testmethodrunner branch July 8, 2026 12:43
github-actions Bot added a commit that referenced this pull request Jul 8, 2026
Apply two project-convention improvements to files added in recent PRs:

- MSTestTestNodeConverter.cs (added in #9706): replace Substring calls
  with range operators per csharp_style_prefer_range_operator = true
- TestMethodRunner.DataSource.cs (added in #9729): replace == null with
  is null per the project's 'always use is null / is not null' rule

No behavioral change; builds verified to succeed with 0 errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file-diet] Split TestMethodRunner.cs into focused partial-class files

3 participants