Skip to content

MTP-hosted xUnit v3 in VS Test Explorer: TestContext.Current.CancellationToken and RunTestCases token both fail to fire on Stop #452

Description

@MhKarapetyan

Under xUnit v3 hosted by Microsoft Testing Platform in VS 2026 18.5.x's
DevHub-hosted Test Explorer, pressing Stop Test Run does not fire any
cancellation token that the test code or a custom XunitTestFrameworkExecutor
override can observe.

How to reproduce

  1. dotnet build this folder (or open StopRepro.csproj in VS).
  2. In VS Test Explorer, Run Token_Should_Fire_When_Test_Explorer_Stop_Is_Pressed.
  3. After ~5 seconds (you'll see poll heartbeats appearing in the log), press
    Stop Test Run in Test Explorer.
  4. Wait at least 30 seconds. Do not stop VS / close anything else.
  5. Open the log file:
    %TEMP%\stop_repro.log
    

Observed output (bug)

None of those appears. The log only contains:

… [Executor] RunTestCases token: CanBeCanceled=True, AlreadyCancelled=False
… [Test] TEST STARTED. …
… [Test] TestContext token: CanBeCanceled=True, AlreadyCancelled=False
… [Test] poll #10, IsCancellationRequested=False
… [Test] poll #20, IsCancellationRequested=False
…
… [Test] TIMED OUT after N polls. Token never fired. 

[StopRepro.zip](https://github.com/user-attachments/files/28453115/StopRepro.zip)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions