Skip to content

Fix bug in conditionaltheory for xunit3 and add Helix SDK support#16537

Merged
agocke merged 6 commits intodotnet:mainfrom
agocke:fix-condition
Feb 23, 2026
Merged

Fix bug in conditionaltheory for xunit3 and add Helix SDK support#16537
agocke merged 6 commits intodotnet:mainfrom
agocke:fix-condition

Conversation

@agocke
Copy link
Member

@agocke agocke commented Feb 19, 2026

The xunit3 discovery code didn't properly pass down the test method arguments, meaning that theories didn't work properly in xunit3 with ConditionalTheory.

This PR simplifies things by moving away from the Discovery implementation entirely in xunit3. The modern fact/theory implementations in xunit3 are fine for implementing the functionality we want.

The only thing we can't do in the new system is ConditionalTheory with only a member name. I've added an obsolete attribute for those cases. It looks like there are relatively few in use and should be easily moved over when adopting xunit3.

To double check:

The xunit3 discovery code didn't properly pass down the test method
arguments, meaning that theories didn't work properly in xunit3 with
ConditionalTheory.

This PR simplifies things by moving away from the Discovery
implementation entirely in xunit3. The modern fact/theory
implementations in xunit3 are fine for implementing the functionality we
want.

The only thing we can't do in the new system is ConditionalTheory with
only a member name. I've added an obsolete attribute for those cases. It
looks like there are relatively few in use and should be easily moved
over when adopting xunit3.
@agocke agocke enabled auto-merge (squash) February 19, 2026 20:04
@agocke agocke requested review from a team and ViktorHofer February 19, 2026 20:04
@agocke
Copy link
Member Author

agocke commented Feb 20, 2026

Cc @elinor-fung

Updated summary comment to clarify the purpose of ordering test cases.
@agocke
Copy link
Member Author

agocke commented Feb 20, 2026

FYI this is blocking more adoption of xunit3 in dotnet/runtime, so it would it be great if it could get merged soon.

akoeplinger
akoeplinger previously approved these changes Feb 22, 2026
The new Microsoft.DotNet.XUnitV3Extensions.Tests project was being picked
up by the XUnitProject glob in UnitTests.proj and run with the XUnit v2
console runner. XUnit v3 tests are self-hosting executables and cannot use
the v2 runner, causing the FailingXUnitTestsTest work item's expected
failure (ExerciseXunitCharacterFilteringFailurePath) to be disrupted.

This adds proper XUnitV3Project support to the Helix SDK:
- XUnitV3Runner.props/targets: restore, build, and create work items
  for XUnit v3 self-hosting test projects
- CreateXUnitV3WorkItems task: generates dotnet exec commands that run
  the test assembly directly (no external console runner needed)
- UnitTests.proj: moves the v3 test project from XUnitProject to
  XUnitV3Project

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@akoeplinger
Copy link
Member

tests weren't running because of #16536, that uncovered that we didn't run any xunitv3 tests here before with the Helix sdk. I asked Copilot to add support.

akoeplinger and others added 2 commits February 22, 2026 15:36
Add UseMicrosoftTestingPlatformRunner property to CreateXUnitV3WorkItems
task and XUnitV3Runner.targets. When true (the default, matching Arcade
SDK's XUnitV3.targets), uses MTP-style arguments (--report-xunit,
--auto-reporters off). When false, uses legacy arguments (-xml,
-noAutoReporters).

Also removes the forced UseMicrosoftTestingPlatformRunner=false from the
publish/restore MSBuild invocations so the project's own MTP default
flows through.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add XUnit v3 runner documentation to the Helix SDK Readme.md and
SendingJobsToHelix.md, describing XUnitV3Project items and the
UseMicrosoftTestingPlatformRunner property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@akoeplinger akoeplinger changed the title Fix bug in conditionaltheory for xunit3 Fix bug in conditionaltheory for xunit3 and add Helix SDK support Feb 22, 2026
@agocke agocke merged commit 0831f9c into dotnet:main Feb 23, 2026
13 checks passed
@agocke agocke deleted the fix-condition branch February 23, 2026 16:07
? "--results-directory . --report-xunit --report-xunit-filename testResults.xml --auto-reporters off"
: "-xml testResults.xml -noAutoReporters";

string command = $"{PathToDotnet} exec --roll-forward Major " +
Copy link
Member

Choose a reason for hiding this comment

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

@agocke This will run using the Architecture of the resolved dotnet right? So if a project sets RuntimeIdentifier to force apphost with specific architecture, that won't be respected?

{
{ "Identity", assemblyName },
{ "PayloadDirectory", publishDirectory },
{ "Command", command },
Copy link
Member

Choose a reason for hiding this comment

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

Should we simplify this to basically just use RunCommand and RunArguments MSBuild properties (after running ComputeRunArguments target)?

This also makes sure that stuff like TestingPlatformCommandLineArguments are considered, and ensures we are using the apphost instead of dotnet exec

akoeplinger added a commit to dotnet/runtime that referenced this pull request Feb 25, 2026
Required for xunit v3 and the other ctor is marked obsolete as of
dotnet/arcade#16537
iremyux pushed a commit to iremyux/dotnet-runtime that referenced this pull request Mar 2, 2026
…24791)

Required for xunit v3 and the other ctor is marked obsolete as of
dotnet/arcade#16537
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.

4 participants