Repository navigation
Add --test-runner option to nunit templates - #54638
Merged
Evangelink merged 4 commits intoJun 8, 2026
Merged
Conversation
Adds a TestRunner choice parameter (VSTest default, Microsoft.Testing.Platform opt-in) to the C#, F#, and VB nunit templates, mirroring the naming used by the mstest and xunit templates. For the MTP path: - sets EnableNUnitRunner=true, IsTestingPlatformApplication=true, OutputType=Exe - bumps NUnit3TestAdapter to 6.2.0 (which transitively brings Microsoft.Testing.Platform 2.1.0, the protocol version required by the .NET 10+ SDK dotnet test orchestrator) - drops coverlet.collector (incompatible with the NUnit MTP runner) - for F#: excludes Program.fs (MTP auto-generates the entry point) and uses a nested module name (Company.TestProject1.Tests) to avoid a namespace/module collision with the generated entry point - creates/updates global.json with the test runner property Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a --test-runner choice parameter to the built-in nunit project templates (C#/F#/VB) so newly created NUnit projects can opt into Microsoft.Testing.Platform (while keeping VSTest as the default), and adds integration-test coverage for the new combinations.
Changes:
- Introduces a
TestRunnerchoice symbol (VSTestdefault,Microsoft.Testing.Platformopt-in) across NUnit templates, including CLI/IDE host wiring and English localization. - Updates generated project files to switch to the MTP runner shape (properties, conditional package references,
global.jsonpost-action). - Adds an integration test covering 3 languages × 2 runners to validate template install +
dotnet testsuccess.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs | Adds NUnit template integration coverage for both VSTest and MTP runners. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-CSharp/Company.TestProject1.csproj | Adds MTP runner properties and conditional package refs for the C# NUnit template. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-CSharp/.template.config/template.json | Adds TestRunner symbol and MTP global.json post-action for the C# NUnit template. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-CSharp/.template.config/localize/templatestrings.en.json | Adds English localization for TestRunner and the global.json post-action (C#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-CSharp/.template.config/ide.host.json | Enables IDE persistence/visibility for TestRunner (C#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-CSharp/.template.config/dotnetcli.host.json | Wires --test-runner CLI alias (C#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/UnitTest1.fs | Adjusts module name under MTP to avoid entrypoint/module collisions. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/Company.TestProject1.fsproj | Adds MTP runner properties, excludes Program.fs for MTP, and updates conditional package refs. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/.template.config/template.json | Adds TestRunner symbol, excludes Program.fs under MTP, and adds MTP global.json post-action. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/.template.config/localize/templatestrings.en.json | Adds English localization for TestRunner and the global.json post-action (F#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/.template.config/ide.host.json | Enables IDE persistence/visibility for TestRunner (F#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-FSharp/.template.config/dotnetcli.host.json | Wires --test-runner CLI alias (F#). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-VisualBasic/Company.TestProject1.vbproj | Adds MTP runner properties and conditional package refs for the VB NUnit template. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-VisualBasic/.template.config/template.json | Adds TestRunner symbol and MTP global.json post-action for the VB NUnit template. |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-VisualBasic/.template.config/localize/templatestrings.en.json | Adds English localization for TestRunner and the global.json post-action (VB). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-VisualBasic/.template.config/ide.host.json | Enables IDE persistence/visibility for TestRunner (VB). |
| template_feed/Microsoft.DotNet.Common.ProjectTemplates.11.0/content/NUnit-VisualBasic/.template.config/dotnetcli.host.json | Wires --test-runner CLI alias (VB). |
Copilot's findings
- Files reviewed: 17/17 changed files
- Comments generated: 3
Evangelink
force-pushed
the
dev/amauryleve/nunit-template-mtp-option
branch
from
June 8, 2026 13:41
33b8d92 to
31ec589
Compare
Move Microsoft.NET.Test.Sdk and NUnit3TestAdapter into the TestRunner != "Microsoft.Testing.Platform" conditional block in the NUnit C#, F#, and VB templates. Both packages are VSTest-specific and pull in unnecessary/possibly conflicting test platform assets when the MTP runner is selected, mirroring how the MSTest template handles its MTP path. Co-authored-by: Copilot <[email protected]>
Evangelink
enabled auto-merge
June 8, 2026 14:15
Evangelink
commented
Jun 8, 2026
Evangelink
commented
Jun 8, 2026
Evangelink
commented
Jun 8, 2026
Evangelink
commented
Jun 8, 2026
Co-authored-by: Amaury Levé <[email protected]>
Evangelink
commented
Jun 8, 2026
Evangelink
commented
Jun 8, 2026
Evangelink
commented
Jun 8, 2026
Co-authored-by: Amaury Levé <[email protected]>
YuliiaKovalova
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partial fix for #54499 — companion to #54636 (which added the same option to the xunit templates).
This PR adds a
TestRunnerchoice parameter to thenunitproject templates (C#, F#, VB), mirroring the option already exposed by themstestandxunittemplates:--test-runner VSTest(default) — preserves existing behavior, no changes to existing users.--test-runner Microsoft.Testing.Platform— opts in to the MTP runner.MTP path details
When
Microsoft.Testing.Platformis selected the generated project:EnableNUnitRunner=true,IsTestingPlatformApplication=true,OutputType=Exe;NUnit3TestAdapterfrom 5.0.0 to 6.2.0 — required because 5.0.0 transitively pinsMicrosoft.Testing.Platform1.5.3, which uses an older handshake protocol incompatible with the .NET 10+ SDKdotnet testorchestrator. 6.2.0 pulls in MTP 2.1.0. The bump is conditional, so the VSTest path keeps the existing 5.0.0 pin and is not affected;coverlet.collector(incompatible with the NUnit MTP runner per Microsoft docs);Program.fs(MTP auto-generates the entry point) and renames the test module toCompany.TestProject1.Teststo avoid a namespace/module collision with the generated entry point;global.jsonwith"runner": "Microsoft.Testing.Platform"via anaddJsonPropertypost-action.Tests
Added
NUnitProjectTemplate_WithTestRunner_CanBeInstalledAndTestsArePassingtoDotnetNewTestTemplatesTests, covering 3 languages × 2 runners = 6 cases. All 6 pass locally.Localization
Only
templatestrings.en.jsonis updated. The.xlffiles will need a follow-up/t:UpdateXlfpass.