8000 Support XUnitV3 as test runner by Youssef1313 · Pull Request #15671 · dotnet/arcade · GitHub
[go: up one dir, main page]

Skip to content

Support XUnitV3 as test runner #15671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 14, 2025
Merged

Support XUnitV3 as test runner #15671

merged 14 commits into from
Apr 14, 2025

Conversation

Youssef1313
Copy link
Member
@Youssef1313 Youssef1313 commented Mar 26, 2025

This PR was manually validated locally, both with UseMicrosoftTestingPlatformRunner set to true and false.

Related to #15654

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/xunit.v3-targets branch from 1a4aa04 to b4b8eae Compare March 26, 2025 16:04
Comment on lines +32 to +33
<!-- Microsoft.NET.Test.Sdk is VSTest-specific package. -->
<!-- If EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner is true, then the repo is using Microsoft.Testing.Platform -->
Copy link
Member Author
@Youssef1313 Youssef1313 Mar 27, 2025

Choose a reason for hiding this comment

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

This is technically breaking.

If a repo is setting EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner but is not either opting-in via dotnet.config or TestingPlatformCommandLineArguments, then their setup will actually be using VSTest when invoking dotnet test directly.

This also means that such repos are not properly configured to use MTP, where the intent may be to use it. So I think it may be reasonable to break, but I'll let you decide.

Comment on lines +20 to +23
<PropertyGroup Condition="'$(_TestRuntime)' == 'Core'">
<_TestRunnerArgs Condition="'$(UseMicrosoftTestingPlatformRunner)' != 'true'">$(_TestRunnerArgs) -noAutoReporters</_TestRunnerArgs>
<_TestRunnerArgs Condition="'$(UseMicrosoftTestingPlatformRunner)' == 'true'">$(_TestRunnerArgs) --auto-reporters off</_TestRunnerArgs>
</PropertyGroup>
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm using the same '$(_TestRuntime)' == 'Core' condition as in xunit v2. But I'm not following why this only applies for .NET Core

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/xunit.v3-targets branch from 84d7db7 to 22cae6c Compare March 28, 2025 15:01
@Youssef1313 Youssef1313 marked this pull request as ready for review March 31, 2025 06:43
8000
WorkingDirectory="$(_TargetDir)"
IgnoreExitCode="true"
Timeout="$(_TestTimeout)"
EnvironmentVariables="DOTNET_ROOT=$(DotNetRoot);DOTNET_ROOT_X86=$(DotNetRoot)x86"
Copy link
Member Author
@Youssef1313 Youssef1313 Mar 31, 2025

Choose a reason for hiding this comment

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

@ViktorHofer Can you please confirm if this is a fine thing to do?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this one. @agocke @vitek-karas can you please chime in here?

Copy link
Member
@ViktorHofer ViktorHofer Apr 10, 2025

Choose a reason for hiding this comment

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

With the .runsettings file, we specify the DotNetHostPath which is used to execute vstest's testhost.dll today: https://github.com/dotnet/runtime/blob/b1d93d078659f71068715b5fc5a1843d64395490/eng/testing/.runsettings#L20

How does that work now? IOW how is the DOTNET_ROOT variable used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ViktorHofer xunit.v3 (both with VSTest and MTP), as well as all frameworks with MTP, will launch test executable directly. The reason I needed to set DOTNET_ROOT here is for the test executable to be able to find the correct runtimes from potentially locally installed SDK. That's how it currently works. As for MTP itself, we don't alter anything in ways that VSTest did in the past.

We may decide to alter DOTNET_ROOT for dotnet test command on the SDK side of things, which is already an open question for us, but dotnet test is irrelevant to what Arcade does here.

Copy link
Member

Choose a reason for hiding this comment

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

I see, that makes sense to me. Does this mean that with this line, you are setting DOTNET_ROOT to the acquired SDK (which if it isn't available is located under repo/.dotnet/?

We should add an indirection property so that repos that build their own DOTNET_ROOT (runtime, sdk, ...) can set this to something else. I.e. <TestDotNetRoot Condition="'$(TestDotNetRoot)' == ''">$(DotNetRoot)</TestDotNetRoot>.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's usually RepoRoot/.dotnet yes. I added the indirection property TestDotNetRoot.

@Youssef1313
Copy link
Member Author

@ViktorHofer I addressed/answered your comments. Let me know if you have any further questions/concerns.

@ViktorHofer
Copy link
Member

I will take a closer look tomorrow.

@Youssef1313 Youssef1313 mentioned this pull request Apr 2, 2025
18 tasks
@Youssef1313 Youssef1313 marked this pull request as draft April 2, 2025 09:08
@Youssef1313
Copy link
Member Author

Converting to draft. I need to do more manual validation here

@Youssef1313 Youssef1313 marked this pull request as ready for review April 3, 2025 14:26
nohwnd
nohwnd previously approved these changes Apr 3, 2025
@Youssef1313 Youssef1313 requested a review from ViktorHofer April 4, 2025 17:44
@Youssef1313
Copy link
Member Author

@ViktorHofer This is ready for review

@ViktorHofer
Copy link
Member

As I noticed that you already merged the aspire PR, a follow-up question: Was this an orthogonal effort or will this PR make some of the files in aspire obsolete?

@RussKie
Copy link
Contributor
RussKie commented Apr 10, 2025

I think the aspire will be cleaned up once this goes in.

ViktorHofer
ViktorHofer previously approved these changes Apr 10, 2025
Copy link
Member
@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

Looks good so far. We should figure the DOTNET_ROOT one out though. Especially, for repositories like runtime that want to set this to the just live built DOTNET_ROOT (aka testhost folder). It might make sense to allow to overwrite that by using an additional property as indirection. We can't overwrite DotNetRoot directly.

@Youssef1313
Copy link
Member Author

@ViktorHofer I added TestDotNetRoot property. Do you think this is ready now?

@Youssef1313
Copy link
Member Author

@ViktorHofer I'm assuming this is hopefully good to merge, and it's low risk in case of bugs anyways. We can then start looking into repos that are easy to switch and see how things will go.

@Youssef1313 Youssef1313 merged commit bc8dfb5 into main Apr 14, 2025
11 checks passed
@Youssef1313 Youssef1313 deleted the dev/ygerges/xunit.v3-targets branch April 14, 2025 07:04
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
0