Skip to content

Migrate sdk-tasks.Tests, trustedroots.Tests and Microsoft.DotNet.MSBuildSdkResolver.Tests to MSTest.Sdk on MTP#54897

Merged
Evangelink merged 4 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-coresdk-misc-tests
Jun 22, 2026
Merged

Migrate sdk-tasks.Tests, trustedroots.Tests and Microsoft.DotNet.MSBuildSdkResolver.Tests to MSTest.Sdk on MTP#54897
Evangelink merged 4 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-coresdk-misc-tests

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Part of the ongoing xUnit -> MSTest.Sdk (MTP) test migration of the .NET SDK test suite, following the same pattern as the other open migration PRs (builds on the foundation merged in #54845).

Covers three small projects. Microsoft.DotNet.MSBuildSdkResolver.Tests disables parallelization ([assembly: DoNotParallelize] + empty MSTestParallelizeScope) to preserve the previous xUnit CollectionBehavior(DisableTestParallelization = true).

Standard transformations: Microsoft.NET.Sdk -> MSTest.Sdk, the TestFramework project reference -> Microsoft.NET.TestFramework.MSTest, [Fact]/[Theory] -> [TestMethod], [InlineData] -> [DataRow], xUnit asserts -> MSTest (including the repo Recommended-mode idiomatic asserts), and ITestOutputHelper constructor injection removed in favour of the base SdkTest Log / TestContext.

Builds clean for the SDK target framework.

…SdkResolver.Tests to MSTest.Sdk on MTP

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates three SDK test projects (sdk-tasks.Tests, trustedroots.Tests, and Microsoft.DotNet.MSBuildSdkResolver.Tests) from xUnit to MSTest.Sdk running on Microsoft Testing Platform (MTP), aligning them with the repo’s ongoing test-suite migration approach.

Changes:

  • Converted project files to Project Sdk="MSTest.Sdk" and switched test framework references to Microsoft.NET.TestFramework.MSTest.
  • Updated test sources from xUnit attributes/constructors ([Fact], [Theory], ITestOutputHelper) to MSTest equivalents ([TestClass], [TestMethod], [DataRow]) and MSTest-style assertions where applicable.
  • Preserved prior execution semantics where needed (notably disabling parallelization for Microsoft.DotNet.MSBuildSdkResolver.Tests via [assembly: DoNotParallelize] plus project-level parallelize scope override).
Show a summary per file
File Description
test/trustedroots.Tests/trustedroots.Tests.csproj Switches project to MSTest.Sdk, updates test framework reference, and adds required global Using for Microsoft.NET.TestFramework.
test/trustedroots.Tests/GivenTimestampingCtlFile.cs Adds MSTest discovery/data-driven attributes ([TestClass], [TestMethod], [DataRow]).
test/trustedroots.Tests/GivenNuGetPackagingDllAndBundleLayout.cs Removes xUnit ctor injection pattern and migrates test to MSTest attributes.
test/trustedroots.Tests/GivenCodeSigningCtlFile.cs Adds MSTest discovery/data-driven attributes ([TestClass], [TestMethod], [DataRow]).
test/sdk-tasks.Tests/sdk-tasks.Tests.csproj Switches project to MSTest.Sdk, updates test framework reference, and adds necessary Microsoft.NET.TestFramework.* global usings.
test/sdk-tasks.Tests/UpdateRuntimeConfigTests.cs Migrates xUnit-based tests to MSTest ([TestClass]/[TestMethod]).
test/sdk-tasks.Tests/RemoveAssetFromDepsPackagesTests.cs Migrates xUnit-based tests to MSTest ([TestClass]/[TestMethod]).
test/sdk-tasks.Tests/PublishMutationUtilitiesTests.cs Migrates xUnit-based tests to MSTest ([TestClass]/[TestMethod]).
test/sdk-tasks.Tests/GenerateDefaultRuntimeFrameworkVersionTests.cs Migrates parameterized tests to MSTest ([TestMethod] + [DataRow]).
test/sdk-tasks.Tests/FilterItemsByDuplicateHashTests.cs Migrates tests to MSTest and updates attributes under #if !NETFRAMEWORK.
test/sdk-tasks.Tests/DeduplicateAssembliesWithLinksTests.cs Migrates multiple tests to MSTest attributes under #if !NETFRAMEWORK.
test/sdk-tasks.Tests/CopyPreservingRelativeSymlinksTests.cs Migrates many tests to MSTest attributes under #if !NETFRAMEWORK.
test/sdk-tasks.Tests/CalculateTemplateVerionsTests.cs Migrates tests to MSTest ([TestClass]/[TestMethod]).
test/Microsoft.DotNet.MSBuildSdkResolver.Tests/Microsoft.DotNet.MSBuildSdkResolver.Tests.csproj Switches project to MSTest.Sdk, updates framework reference, and configures parallelization behavior for process-global-state tests.
test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenThatWeWantToParseSemanticVersions.cs Migrates xUnit theories/facts to MSTest ([TestClass], [TestMethod], [DataRow]).
test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenThatIWantToCompareSemanticVersions.cs Migrates xUnit theories/facts to MSTest ([TestClass], [TestMethod], [DataRow]).
test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnMSBuildSdkResolver.cs Replaces xUnit assembly parallelization configuration with MSTest [assembly: DoNotParallelize] and migrates tests/assertions.
test/Microsoft.DotNet.MSBuildSdkResolver.Tests/GivenAnEnvironmentForResolution.cs Removes xUnit ctor injection and migrates tests to MSTest attributes.

Copilot's findings

  • Files reviewed: 18/18 changed files
  • Comments generated: 0

@Evangelink Evangelink enabled auto-merge June 20, 2026 07:47
Evangelink and others added 3 commits June 20, 2026 09:47
The CreateSourceAndDestDirs helper called CreateTestDirectory() without a name, so [CallerMemberName] resolved to the helper name for every test. All test methods shared one base directory name, and under MSTest MethodLevel parallelism the CI dedup loop's check-then-act raced, picking the same _N directory and colliding on file writes (file in use by another process).

Forward the actual test method name so each test gets a unique directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g package install test: Microsoft.DotNet.PackageInstall.Tests.ToolPackageDownloaderTests.GivenFailureWhenInstallLocalToolsItWillRollbackPackageVersion(testMockBehaviorIsInSync: False)

Message

Expected boolean to be False, but found True.

@Evangelink Evangelink merged commit a9975fa into dotnet:main Jun 22, 2026
23 of 25 checks passed
@Evangelink Evangelink deleted the evangelink/mstest-mtp-coresdk-misc-tests branch June 22, 2026 18:27
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.

3 participants