Fix bug in conditionaltheory for xunit3 and add Helix SDK support#16537
Fix bug in conditionaltheory for xunit3 and add Helix SDK support#16537agocke merged 6 commits intodotnet:mainfrom
Conversation
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.
|
Cc @elinor-fung |
src/Microsoft.DotNet.XUnitExtensions.Shared/Attributes/ConditionalTheoryAttribute.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.XUnitV3Extensions/tests/AlphabeticalOrderer.cs
Outdated
Show resolved
Hide resolved
Updated summary comment to clarify the purpose of ordering test cases.
|
FYI this is blocking more adoption of xunit3 in dotnet/runtime, so it would it be great if it could get merged soon. |
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>
|
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. |
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>
| ? "--results-directory . --report-xunit --report-xunit-filename testResults.xml --auto-reporters off" | ||
| : "-xml testResults.xml -noAutoReporters"; | ||
|
|
||
| string command = $"{PathToDotnet} exec --roll-forward Major " + |
There was a problem hiding this comment.
@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 }, |
There was a problem hiding this comment.
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
Required for xunit v3 and the other ctor is marked obsolete as of dotnet/arcade#16537
…24791) Required for xunit v3 and the other ctor is marked obsolete as of dotnet/arcade#16537
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: