Allow a trailing CancellationToken parameter on MSTest test methods
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
The proposal touches MSTest test discovery, execution (both reflection and source-generated paths), argument binding for DataRow and DynamicData, and the MSTest analyzers, so start by tracing how TestContext.CancellationToken is currently made available to a test body. Done means a test method with a trailing CancellationToken parameter receives the same token as TestContext, data-driven methods bind their data arguments unchanged, and invalid signatures are rejected consistently across discovery, execution and analyzers. The issue has no assignee or pull request yet, but the design spans several subsystems, so confirm the approach with maintainers before writing code.
索引モデルが issue の本文から書いたものです。
説明
Summary
Allow MSTest test methods to declare one additional trailing CancellationToken parameter. MSTest supplies TestContext.CancellationToken automatically, so a non-parameterized test can take one parameter and a parameterized test with X data arguments can take X + 1 parameters.
Background and Motivation
Tests currently need access to TestContext just to forward its cancellation token to asynchronous operations. A method parameter makes cooperative cancellation explicit and avoids that boilerplate.
Proposed Feature
[TestMethod]
public async Task TestAsync(CancellationToken cancellationToken)
{
await RunAsync(cancellationToken);
}
[TestMethod]
[DataRow(42)]
public async Task ParameterizedTestAsync(int value, CancellationToken cancellationToken)
{
await RunAsync(value, cancellationToken);
}
- Inject the exact current
TestContext.CancellationToken, preserving its existing cancellation and timeout lifetime. - Support ordinary methods and data-driven methods, including
DataRowandDynamicData. - Keep discovery, reflection/source-generated execution, argument validation, and MSTest analyzers consistent.
- Preserve existing test signatures and data binding; do not inject arbitrary parameters or change lifecycle method signatures.
- Add regression coverage for token identity, cancellation, data arguments, invalid signatures, and existing behavior.
Alternative Designs
Continue using TestContext.CancellationToken inside the test body. No new attribute or general dependency-injection mechanism is needed for the proposed convenience.
- 主要言語
- C#
- スター
- 1.1k
- フォーク
- 312
- 平均マージ
- 11時間 6分
- マージ済み PR(30日)
- 326
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/testfx のほかの issue
-
type/automation type/test-gap
難易度 3/5 半日 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
needs/triage
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
The productive version of Microsoft.Testing.Extensions.HangDump must not reference to a preview version of Microsoft.Diagnostics.NETCore.Client対応中かも @Evangelink が 6 日前に担当しました。 オープンarea/dump external/other
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
microsoft/testfx#11981 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
type/automation type/tech-debt
難易度 5/5 1週間以上 初心者へのやさしさ 5/100
メンテナーはふだん 1 日以内に返信
-
area/server-mode-jsonrpc
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
メンテナーはふだん 1 日以内に返信
microsoft/testfx の issue をすべて見る
似ている issue
-
bug evaluation required
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#4118 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
[Format]: .dartオープンformats
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
KnifeLemon/Filee#980 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信