-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add --test-runner option to global.json template #50757
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
base: main
Are you sure you want to change the base?
Conversation
--test-runner
option
...feed/Microsoft.DotNet.Common.ItemTemplates/content/GlobalJson/.template.config/template.json
Outdated
Show resolved
Hide resolved
template_feed/Microsoft.DotNet.Common.ItemTemplates/content/GlobalJson/global.json
Outdated
Show resolved
Hide resolved
5640f2d
to
0643f53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new --test-runner
option to the global.json template, allowing users to specify which test runner to use when creating global.json files. The PR implements template parameter support for VSTest and Microsoft.Testing.Platform runners, includes comprehensive localization, and adds integration tests to verify the functionality.
Key Changes
- Added TestRunner parameter to global.json template with VSTest and Microsoft.Testing.Platform choices
- Updated global.json template logic to conditionally include test section based on the parameter
- Added comprehensive integration tests covering various parameter combinations
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 15 comments.
Show a summary per file
File | Description |
---|---|
template.json | Adds TestRunner parameter configuration with choice options |
global.json | Updates template to conditionally include test runner configuration |
dotnetcli.host.json | Maps TestRunner parameter to --test-runner CLI option |
CommonTemplatesTests.cs | Adds integration test cases for new test runner functionality |
templatestrings.*.json | Provides localization strings for all supported languages |
DotnetNewHelpTests verification file | Updates expected help output to include new test-runner option |
[InlineData("global.json file", "globaljson", new[] { "--TestRunner", "VSTest" })] | ||
[InlineData("global.json file", "globaljson", new[] { "--TestRunner", "Microsoft.Testing.Platform" })] | ||
[InlineData("global.json file", "globaljson", new[] { "--sdk-version", "6.0.200", "--TestRunner", "VSTest" })] | ||
[InlineData("global.json file", "globaljson", new[] { "--roll-forward", "major", "--TestRunner", "Microsoft.Testing.Platform" })] | ||
[InlineData("global.json file", "global.json", null)] | ||
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200" })] | ||
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200", "--roll-forward", "major" })] | ||
[InlineData("global.json file", "global.json", new[] { "--TestRunner", "VSTest" })] | ||
[InlineData("global.json file", "global.json", new[] { "--TestRunner", "Microsoft.Testing.Platform" })] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name should use lowercase format --test-runner
instead of --TestRunner
to match the CLI convention used in the existing test cases and the configuration in dotnetcli.host.json.
[InlineData("global.json file", "globaljson", new[] { "--TestRunner", "VSTest" })] | |
[InlineData("global.json file", "globaljson", new[] { "--TestRunner", "Microsoft.Testing.Platform" })] | |
[InlineData("global.json file", "globaljson", new[] { "--sdk-version", "6.0.200", "--TestRunner", "VSTest" })] | |
[InlineData("global.json file", "globaljson", new[] { "--roll-forward", "major", "--TestRunner", "Microsoft.Testing.Platform" })] | |
[InlineData("global.json file", "global.json", null)] | |
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200" })] | |
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200", "--roll-forward", "major" })] | |
[InlineData("global.json file", "global.json", new[] { "--TestRunner", "VSTest" })] | |
[InlineData("global.json file", "global.json", new[] { "--TestRunner", "Microsoft.Testing.Platform" })] | |
[InlineData("global.json file", "globaljson", new[] { "--test-runner", "VSTest" })] | |
[InlineData("global.json file", "globaljson", new[] { "--test-runner", "Microsoft.Testing.Platform" })] | |
[InlineData("global.json file", "globaljson", new[] { "--sdk-version", "6.0.200", "--test-runner", "VSTest" })] | |
[InlineData("global.json file", "globaljson", new[] { "--roll-forward", "major", "--test-runner", "Microsoft.Testing.Platform" })] | |
[InlineData("global.json file", "global.json", null)] | |
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200" })] | |
[InlineData("global.json file", "global.json", new[] { "--sdk-version", "6.0.200", "--roll-forward", "major" })] | |
[InlineData("global.json file", "global.json", new[] { "--test-runner", "VSTest" })] | |
[InlineData("global.json file", "global.json", new[] { "--test-runner", "Microsoft.Testing.Platform" })] |
Copilot uses AI. Check for mistakes.
Changes Made
Template Configuration: Added
TestRunner
parameter to the global.json template configuration with two supported choices:VSTest
- Use the VSTest test runnerMicrosoft.Testing.Platform
- Use the Microsoft.Testing.Platform test runnerTemplate Logic: Updated the global.json template to conditionally include a
test
section when the--test-runner
option is provided, using template engine conditional syntax.Integration Tests: Added comprehensive test cases to verify the new functionality works correctly with various parameter combinations.
Fixed Parameter Names: Updated both description and displayName for the Microsoft.Testing.Platform choice to use the dotted format "Microsoft.Testing.Platform" instead of "Microsoft Testing Platform" per feedback.
Fixed JSON Formatting: Moved the comma from its own line to the end of the preceding line to follow proper JSON formatting conventions.
Behavior
dotnet new globaljson
→ Creates global.json with only the SDK section (no test section)dotnet new globaljson --test-runner VSTest
→ Creates global.json with SDK section plus test section containing"runner": "VSTest"
dotnet new globaljson --test-runner Microsoft.Testing.Platform
→ Creates global.json with SDK section plus test section containing"runner": "Microsoft.Testing.Platform"
The option supports both long form (
--test-runner
) and short form (-T
), and provides proper error handling for invalid values.Fixes #50753.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.