Skip to content

Migrate Microsoft.DotNet.PackageInstall.Tests to MSTest.Sdk on MTP - #54900

Merged
Evangelink merged 5 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-packageinstall-tests
Jun 22, 2026
Merged

Evangelink merged 5 commits into
dotnet:mainfrom
Evangelink:evangelink/mstest-mtp-packageinstall-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).

Collection/class fixtures (TestToolBuilder, DotnetEnvironmentTestFixture) become a shared static Lazy / [ClassInitialize] with [DoNotParallelize] to preserve serialization. Includes the InternalsVisibleTo grant this project needs and a target to strip the old xUnit framework dll pulled transitively by ComponentMocks.

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.

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

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 Microsoft.DotNet.PackageInstall.Tests from xUnit to MSTest.Sdk (Microsoft Testing Platform) as part of the SDK test suite’s ongoing xUnit → MSTest migration, aligning the project with the new MSTest-based test framework introduced in the referenced foundation work.

Changes:

  • Converted test project and test sources from xUnit attributes/fixtures/output patterns to MSTest.Sdk ([TestClass], [TestMethod], [DataRow], MSTest conditions, SdkTest logging/TestContext).
  • Replaced xUnit collection/class fixtures with MSTest [ClassInitialize]/[ClassCleanup] and a shared static Lazy<TestToolBuilder> plus [DoNotParallelize] where needed.
  • Added MSTest-side InternalsVisibleTo mirroring and project-level reference handling to avoid xUnit framework conflicts pulled transitively.
Show a summary per file
File Description
test/Microsoft.NET.TestFramework.MSTest/InternalsVisibleToAttributes.cs Adds mirrored InternalsVisibleTo grants needed by link-shared internals when using the MSTest-flavored framework assembly.
test/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj Switches project to MSTest.Sdk, references Microsoft.NET.TestFramework.MSTest, adds global usings, and removes conflicting legacy test framework reference.
test/Microsoft.DotNet.PackageInstall.Tests/UnixFilePermissionsTests.cs Converts a unit test class from [Fact] to MSTest [TestClass]/[TestMethod].
test/Microsoft.DotNet.PackageInstall.Tests/ToolPackageUninstallerTests.cs Migrates theory-based Windows-only test to MSTest with OSCondition + DataRow.
test/Microsoft.DotNet.PackageInstall.Tests/ToolPackageInstallerNugetCacheTests.cs Migrates parameterized Windows-only tests to MSTest attributes/conditions and removes xUnit ctor injection.
test/Microsoft.DotNet.PackageInstall.Tests/ToolPackageDownloaderTests.cs Replaces xUnit fixtures/collection usage with MSTest class init/cleanup and shared tool builder usage; converts all tests to MSTest.
test/Microsoft.DotNet.PackageInstall.Tests/ToolConfigurationDeserializerTests.cs Converts multiple xUnit [Fact] tests to MSTest [TestMethod].
test/Microsoft.DotNet.PackageInstall.Tests/TestToolBuilder.cs Removes xUnit collection fixture plumbing and introduces a shared Lazy<TestToolBuilder> instance.
test/Microsoft.DotNet.PackageInstall.Tests/NuGetPackageInstallerTests.cs Migrates test class to MSTest and updates exception assertions to MSTest equivalents.
test/Microsoft.DotNet.PackageInstall.Tests/NuGetPackageInstallerExtractTests.cs Migrates to MSTest and replaces Unix-only gating with OSCondition.
test/Microsoft.DotNet.PackageInstall.Tests/NuGetPackageDownloaderFactoryTests.cs Migrates to MSTest attributes and removes xUnit ctor injection.
test/Microsoft.DotNet.PackageInstall.Tests/LockFileMatcherTests.cs Migrates xUnit theories to MSTest [TestMethod] + [DataRow].
test/Microsoft.DotNet.PackageInstall.Tests/LocalToolsResolverCacheTests.cs Migrates to MSTest and removes xUnit ctor injection.
test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs Migrates end-to-end tests to MSTest, introduces shared tool builder usage + non-parallelization where needed.

Copilot's findings

  • Files reviewed: 14/14 changed files
  • Comments generated: 1

Comment thread test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs Outdated
@Evangelink
Evangelink enabled auto-merge June 20, 2026 08:38
…ration

Keep the xUnit Microsoft.NET.TestFramework in the runtime closure (deps.json)
so ComponentMocks can load it at runtime, removing it from the C# compiler
references only (via ReferencePathWithRefAssemblies after
FindReferenceAssembliesForReferences) instead of ReferenceOutputAssembly=false,
which had dropped it from deps.json and caused FileNotFoundException for
Microsoft.NET.TestFramework, Version=42.42.42.42 at runtime.

Mark ToolPackageInstallToManagedLocationInstaller and ToolPackageUninstallerTests
[DoNotParallelize] since they perform real tool installs into the shared NuGet
global packages folder and raced under MethodLevel parallelism (IOException: the
process cannot access the file ...nupkg because it is being used by another process).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink
Evangelink merged commit c20eb3c into dotnet:main Jun 22, 2026
26 checks passed
@Evangelink
Evangelink deleted the evangelink/mstest-mtp-packageinstall-tests branch June 22, 2026 16:17
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants