Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 11, 2025

  • Add --test-runner option to global.json template
  • Add integration tests for the new option
  • Update TestRunner parameter to use "Microsoft.Testing.Platform" in both description and displayName (addressing @Youssef1313's feedback)
  • Fix comma placement in global.json template (addressing @Youssef1313's feedback)

Changes Made

  1. Template Configuration: Added TestRunner parameter to the global.json template configuration with two supported choices:

    • VSTest - Use the VSTest test runner
    • Microsoft.Testing.Platform - Use the Microsoft.Testing.Platform test runner
  2. Template Logic: Updated the global.json template to conditionally include a test section when the --test-runner option is provided, using template engine conditional syntax.

  3. Integration Tests: Added comprehensive test cases to verify the new functionality works correctly with various parameter combinations.

  4. 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.

  5. 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.

@Copilot Copilot AI changed the title [WIP] global.json template: add --test-runner option Add --test-runner option to global.json template Sep 11, 2025
@Copilot Copilot AI requested a review from Youssef1313 September 11, 2025 12:41
Copilot finished work on behalf of Youssef1313 September 11, 2025 12:41
@Youssef1313 Youssef1313 marked this pull request as ready for review September 14, 2025 10:14
@Youssef1313 Youssef1313 requested a review from a team as a code owner September 14, 2025 10:14
@Copilot Copilot AI review requested due to automatic review settings September 14, 2025 10:14
Copy link
Contributor

@Copilot Copilot AI left a 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

Comment on lines 32 to 40
[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" })]
Copy link
Preview

Copilot AI Sep 14, 2025

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.

Suggested change
[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.

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.

global.json template: add --test-runner option
2 participants