Skip to content

Conversation

mariam-abdulla
Copy link
Member

@mariam-abdulla mariam-abdulla commented Aug 20, 2025

This pull request improves error handling and messaging for the dotnet test command, especially when a project is not runnable or is misconfigured. It introduces a new error message for test command failures, refactors how run properties are retrieved, and ensures consistency in error reporting across different scenarios. Additionally, translations for the new error message have been added for multiple languages.

Error handling and messaging improvements:

  • Added a new error message TestCommandExceptionUnableToRun for cases where dotnet test cannot proceed due to project misconfiguration, including details about the project, command, property, and current value. This message is now used instead of the generic run error in test scenarios. [1] [2]
  • Updated resource files to include translations for TestCommandExceptionUnableToRun in all supported languages, ensuring consistent messaging for global users. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Code refactoring and logic changes:

  • Introduced RunProperties.GetPropsFromProject and RunProperties.ThrowUnableToRunError methods to centralize and clarify how run properties and related errors are handled for test projects.
  • Updated SolutionAndProjectUtility logic to only retrieve run properties for platform test applications and to create minimal run properties for VSTest projects, improving robustness and clarity. [1] [2]
  • Changed internal usage to call the new GetPropsFromProject method instead of the previous FromProject method, aligning with the new error handling flow.

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 14:23
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

This PR fixes error messages in the dotnet CLI by adding a new localized string TestCommandExceptionUnableToRun and updating the error handling logic for test command execution. The changes improve error messaging consistency between run and test commands.

  • Adds a new localized error message specifically for test command execution failures
  • Updates error handling logic to use the correct error message for test scenarios
  • Refactors run properties handling to separate test platform applications from VSTest projects

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

File Description
src/Cli/dotnet/Commands/CliCommandStrings.resx Adds new TestCommandExceptionUnableToRun error message string
src/Cli/dotnet/Commands/xlf/*.xlf Auto-generated localization files with new error message translations
src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs Updates error handling to use test-specific error message and improves run properties logic
src/Cli/dotnet/Commands/Run/RunProperties.cs Refactors to extract common error handling logic and use appropriate error messages

@mariam-abdulla mariam-abdulla changed the title Fix some error messages Fix some error messages in dotnet test Aug 20, 2025
@mariam-abdulla mariam-abdulla enabled auto-merge (squash) August 21, 2025 11:57
@Youssef1313
Copy link
Member

/backport to release/10.0.1xx

Copy link
Contributor

Started backporting to release/10.0.1xx: https://github.com/dotnet/sdk/actions/runs/17127212696

@mariam-abdulla mariam-abdulla merged commit 0b8ab33 into main Aug 21, 2025
27 checks passed
@mariam-abdulla mariam-abdulla deleted the dev/mabdullah/fix-some-error-messages branch August 21, 2025 13:14
@Youssef1313 Youssef1313 linked an issue Aug 27, 2025 that may be closed by this pull request
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.

dotnet test help is broken for MTP when run on solution
3 participants