From b543e912ba4f1144b60823d7dcdc9b164eab9db4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 Aug 2025 09:52:06 +0000 Subject: [PATCH 1/9] Initial plan From 17a9f57a679a4562fd38511f205e44fa4247f311 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 Aug 2025 10:18:51 +0000 Subject: [PATCH 2/9] Implement better error messages for dotnet test with file/directory arguments Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com> --- src/Cli/dotnet/Commands/Test/TestCommand.cs | 80 ++++++++++++++ .../Test/TestCommandParserTests.cs | 1 + .../Test/TestCommandValidationTests.cs | 103 ++++++++++++++++++ 3 files changed, 184 insertions(+) create mode 100644 test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs diff --git a/src/Cli/dotnet/Commands/Test/TestCommand.cs b/src/Cli/dotnet/Commands/Test/TestCommand.cs index 0eba5a75bb79..c0fe0803ad52 100644 --- a/src/Cli/dotnet/Commands/Test/TestCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestCommand.cs @@ -45,6 +45,13 @@ public static int Run(ParseResult parseResult) // all parameters before -- args = [.. args.TakeWhile(a => a != "--")]; + // Check for common patterns that suggest users need to use specific flags + var validationResult = ValidateArgumentsForRequiredFlags(args); + if (validationResult != 0) + { + return validationResult; + } + // Fix for https://github.com/Microsoft/vstest/issues/1453 // Run dll/exe directly using the VSTestForwardingApp if (ContainsBuiltTestSources(args)) @@ -341,6 +348,79 @@ private static Dictionary GetUserSpecifiedExplicitMSBuildPropert } return globalProperties; } + + /// + /// Validates that arguments requiring specific flags are used correctly. + /// Provides helpful error messages when users provide file/directory arguments without proper flags. + /// + /// 0 if validation passes, non-zero error code if validation fails + private static int ValidateArgumentsForRequiredFlags(string[] args) + { + foreach (string arg in args) + { + if (arg.StartsWith("-")) + { + // Skip options/flags + continue; + } + + string? errorMessage = null; + string? suggestedUsage = null; + + // Check for .sln files + if (arg.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) && File.Exists(arg)) + { + errorMessage = $"Solution file '{arg}' was provided as a positional argument."; + suggestedUsage = $"Consider passing the solution as the default target by running: dotnet test (from the solution directory)\n" + + $"Or use the new Testing Platform with: --solution {arg}\n" + + "To enable Testing Platform, create a 'dotnet.config' file with:\n" + + "[dotnet.test.runner]\n" + + "name = Microsoft.Testing.Platform"; + } + // Check for .csproj/.vbproj/.fsproj files + else if ((arg.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || + arg.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) || + arg.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase)) && File.Exists(arg)) + { + errorMessage = $"Project file '{arg}' was provided as a positional argument."; + suggestedUsage = $"Consider passing the project as the default target by running: dotnet test (from the project directory)\n" + + $"Or use the new Testing Platform with: --project {arg}\n" + + "To enable Testing Platform, create a 'dotnet.config' file with:\n" + + "[dotnet.test.runner]\n" + + "name = Microsoft.Testing.Platform"; + } + // Check for directories (if they exist) + else if (Directory.Exists(arg)) + { + errorMessage = $"Directory '{arg}' was provided as a positional argument."; + suggestedUsage = $"Use the new Testing Platform with: --directory {arg}\n" + + "To enable Testing Platform, create a 'dotnet.config' file with:\n" + + "[dotnet.test.runner]\n" + + "name = Microsoft.Testing.Platform"; + } + // Check for .dll or .exe files (but not for VSTest forwarding case) + else if ((arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || + arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && + File.Exists(arg)) + { + errorMessage = $"Test assembly '{arg}' was provided as a positional argument."; + suggestedUsage = $"Use the new Testing Platform with: --test-modules {arg}\n" + + "To enable Testing Platform, create a 'dotnet.config' file with:\n" + + "[dotnet.test.runner]\n" + + "name = Microsoft.Testing.Platform"; + } + + if (errorMessage != null && suggestedUsage != null) + { + Reporter.Error.WriteLine(errorMessage); + Reporter.Error.WriteLine(suggestedUsage); + Reporter.Error.WriteLine("\nFor more information about the available options, run 'dotnet test --help'."); + return 1; + } + } + + return 0; + } } public class TerminalLoggerDetector diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs index 9b86d3c92c4c..c202348b7865 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs @@ -5,6 +5,7 @@ using System.CommandLine; using Microsoft.DotNet.Cli.Commands.Test; +using Microsoft.DotNet.Cli; namespace Microsoft.DotNet.Cli.Test.Tests { diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs new file mode 100644 index 000000000000..494fb33aca05 --- /dev/null +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs @@ -0,0 +1,103 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.DotNet.Tools.Test.Utilities; + +namespace Microsoft.DotNet.Cli.Test.Tests +{ + public class TestCommandValidationTests : SdkTest + { + public TestCommandValidationTests(ITestOutputHelper log) : base(log) + { + } + + [Theory] + [InlineData("MySolution.sln", "Solution file 'MySolution.sln' was provided as a positional argument.")] + [InlineData("MyProject.csproj", "Project file 'MyProject.csproj' was provided as a positional argument.")] + [InlineData("MyProject.vbproj", "Project file 'MyProject.vbproj' was provided as a positional argument.")] + [InlineData("MyProject.fsproj", "Project file 'MyProject.fsproj' was provided as a positional argument.")] + public void TestCommandShouldValidateFileArgumentsAndProvideHelpfulMessages(string filename, string expectedErrorStart) + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Create the test file + var testFilePath = Path.Combine(testDir.Path, filename); + File.WriteAllText(testFilePath, "dummy content"); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute(filename); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain(expectedErrorStart); + result.StdErr.Should().Contain("Testing Platform"); + result.StdErr.Should().Contain("dotnet.config"); + } + + [Fact] + public void TestCommandShouldValidateDirectoryArgumentAndProvideHelpfulMessage() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + var subDir = Path.Combine(testDir.Path, "test_directory"); + Directory.CreateDirectory(subDir); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute("test_directory"); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain("Directory 'test_directory' was provided as a positional argument."); + result.StdErr.Should().Contain("--directory test_directory"); + result.StdErr.Should().Contain("Testing Platform"); + } + + [Fact] + public void TestCommandShouldValidateDllArgumentAndProvideHelpfulMessage() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Create a dummy dll file + var dllPath = Path.Combine(testDir.Path, "test.dll"); + File.WriteAllText(dllPath, "dummy dll content"); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute("test.dll"); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain("Test assembly 'test.dll' was provided as a positional argument."); + result.StdErr.Should().Contain("--test-modules test.dll"); + result.StdErr.Should().Contain("Testing Platform"); + } + + [Fact] + public void TestCommandShouldAllowNormalOptionsWithoutValidation() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Test that normal options like --help still work without triggering validation + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .Execute("--help"); + + result.ExitCode.Should().Be(0); + result.StdOut.Should().Contain("Usage:"); + result.StdOut.Should().Contain("dotnet test"); + } + + [Fact] + public void TestCommandShouldNotValidateNonExistentFiles() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Test that non-existent files with project extensions don't trigger validation + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute("NonExistent.csproj"); + + // This should pass through to MSBuild and give a different error, not our validation error + result.ExitCode.Should().Be(1); + result.StdErr.Should().NotContain("was provided as a positional argument"); + result.StdErr.Should().NotContain("Testing Platform"); + } + } +} \ No newline at end of file From 455bd3bcc0dcc13c9aa7a6b9802a41ca530762b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 Aug 2025 16:12:22 +0000 Subject: [PATCH 3/9] Add validation logic for MTP command to provide better error messages for file/directory arguments Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com> --- .../Commands/Test/TestingPlatformCommand.cs | 72 ++++++++++++++++++- .../Test/TestCommandValidationTests.cs | 72 +++++++++++++++++++ 2 files changed, 143 insertions(+), 1 deletion(-) diff --git a/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs b/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs index 0a72e7d851c4..28a8aa78be2f 100644 --- a/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs @@ -6,12 +6,13 @@ using System.CommandLine; using Microsoft.DotNet.Cli.Commands.Test.Terminal; using Microsoft.DotNet.Cli.Extensions; +using Microsoft.DotNet.Cli.Utils; using Microsoft.TemplateEngine.Cli.Commands; using Microsoft.TemplateEngine.Cli.Help; namespace Microsoft.DotNet.Cli.Commands.Test; -internal partial class TestingPlatformCommand : Command, ICustomHelp +internal partial class TestingPlatformCommand : System.CommandLine.Command, ICustomHelp { private MSBuildHandler _msBuildHandler; private TerminalTestReporter _output; @@ -46,6 +47,13 @@ private int RunInternal(ParseResult parseResult) { ValidationUtility.ValidateMutuallyExclusiveOptions(parseResult); + // Validate arguments for required flags + var validationResult = ValidateArgumentsForRequiredFlags(parseResult); + if (validationResult != 0) + { + return validationResult; + } + PrepareEnvironment(parseResult, out TestOptions testOptions, out int degreeOfParallelism); InitializeOutput(degreeOfParallelism, parseResult, testOptions.IsHelp); @@ -205,4 +213,66 @@ private void CleanUp() { _eventHandlers?.Dispose(); } + + /// + /// Validates that arguments requiring specific flags are used correctly for Microsoft Testing Platform. + /// Provides helpful error messages when users provide file/directory arguments without proper flags. + /// + /// 0 if validation passes, non-zero error code if validation fails + private static int ValidateArgumentsForRequiredFlags(ParseResult parseResult) + { + // Check unmatched tokens for file/directory arguments that should use flags + var unmatchedTokens = parseResult.UnmatchedTokens.ToList(); + + foreach (string token in unmatchedTokens) + { + if (token.StartsWith("-")) + { + // Skip options/flags + continue; + } + + string errorMessage = null; + string suggestedUsage = null; + + // Check for .sln files + if (token.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) && File.Exists(token)) + { + errorMessage = $"Solution file '{token}' was provided as a positional argument."; + suggestedUsage = $"Use the --solution flag: dotnet test --solution {token}"; + } + // Check for .csproj/.vbproj/.fsproj files + else if ((token.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase)) && File.Exists(token)) + { + errorMessage = $"Project file '{token}' was provided as a positional argument."; + suggestedUsage = $"Use the --project flag: dotnet test --project {token}"; + } + // Check for directories (if they exist) + else if (Directory.Exists(token)) + { + errorMessage = $"Directory '{token}' was provided as a positional argument."; + suggestedUsage = $"Use the --directory flag: dotnet test --directory {token}"; + } + // Check for .dll or .exe files + else if ((token.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && + File.Exists(token)) + { + errorMessage = $"Test assembly '{token}' was provided as a positional argument."; + suggestedUsage = $"Use the --test-modules flag: dotnet test --test-modules {token}"; + } + + if (errorMessage != null && suggestedUsage != null) + { + Reporter.Error.WriteLine(errorMessage); + Reporter.Error.WriteLine(suggestedUsage); + Reporter.Error.WriteLine("\nFor more information about the available options, run 'dotnet test --help'."); + return 1; + } + } + + return 0; + } } diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs index 494fb33aca05..ac9ad30ff7aa 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs @@ -99,5 +99,77 @@ public void TestCommandShouldNotValidateNonExistentFiles() result.StdErr.Should().NotContain("was provided as a positional argument"); result.StdErr.Should().NotContain("Testing Platform"); } + + [Theory] + [InlineData("MySolution.sln", "Solution file 'MySolution.sln' was provided as a positional argument.", "--solution MySolution.sln")] + [InlineData("MyProject.csproj", "Project file 'MyProject.csproj' was provided as a positional argument.", "--project MyProject.csproj")] + [InlineData("MyProject.vbproj", "Project file 'MyProject.vbproj' was provided as a positional argument.", "--project MyProject.vbproj")] + [InlineData("MyProject.fsproj", "Project file 'MyProject.fsproj' was provided as a positional argument.", "--project MyProject.fsproj")] + public void TestCommandWithMTPShouldValidateFileArgumentsAndProvideDirectGuidance(string filename, string expectedErrorStart, string expectedSuggestion) + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Create dotnet.config to enable MTP + var configPath = Path.Combine(testDir.Path, "dotnet.config"); + File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); + + // Create the test file + var testFilePath = Path.Combine(testDir.Path, filename); + File.WriteAllText(testFilePath, "dummy content"); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute(filename); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain(expectedErrorStart); + result.StdErr.Should().Contain(expectedSuggestion); + result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled, so no need to suggest enabling it + } + + [Fact] + public void TestCommandWithMTPShouldValidateDirectoryArgumentAndProvideDirectGuidance() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Create dotnet.config to enable MTP + var configPath = Path.Combine(testDir.Path, "dotnet.config"); + File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); + + var subDir = Path.Combine(testDir.Path, "test_directory"); + Directory.CreateDirectory(subDir); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute("test_directory"); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain("Directory 'test_directory' was provided as a positional argument."); + result.StdErr.Should().Contain("--directory test_directory"); + result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled + } + + [Fact] + public void TestCommandWithMTPShouldValidateDllArgumentAndProvideDirectGuidance() + { + var testDir = _testAssetsManager.CreateTestDirectory(); + + // Create dotnet.config to enable MTP + var configPath = Path.Combine(testDir.Path, "dotnet.config"); + File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); + + // Create a dummy dll file + var dllPath = Path.Combine(testDir.Path, "test.dll"); + File.WriteAllText(dllPath, "dummy dll content"); + + var result = new DotnetTestCommand(Log, disableNewOutput: true) + .WithWorkingDirectory(testDir.Path) + .Execute("test.dll"); + + result.ExitCode.Should().Be(1); + result.StdErr.Should().Contain("Test assembly 'test.dll' was provided as a positional argument."); + result.StdErr.Should().Contain("--test-modules test.dll"); + result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled + } } } \ No newline at end of file From 8c23e197a2fd7d631701a88618e4d8a2f7f5f90e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:34:20 +0000 Subject: [PATCH 4/9] Revert all changes to TestCommand.cs as requested by review feedback Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com> --- src/Cli/dotnet/Commands/Test/TestCommand.cs | 80 --------------------- 1 file changed, 80 deletions(-) diff --git a/src/Cli/dotnet/Commands/Test/TestCommand.cs b/src/Cli/dotnet/Commands/Test/TestCommand.cs index c0fe0803ad52..0eba5a75bb79 100644 --- a/src/Cli/dotnet/Commands/Test/TestCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestCommand.cs @@ -45,13 +45,6 @@ public static int Run(ParseResult parseResult) // all parameters before -- args = [.. args.TakeWhile(a => a != "--")]; - // Check for common patterns that suggest users need to use specific flags - var validationResult = ValidateArgumentsForRequiredFlags(args); - if (validationResult != 0) - { - return validationResult; - } - // Fix for https://github.com/Microsoft/vstest/issues/1453 // Run dll/exe directly using the VSTestForwardingApp if (ContainsBuiltTestSources(args)) @@ -348,79 +341,6 @@ private static Dictionary GetUserSpecifiedExplicitMSBuildPropert } return globalProperties; } - - /// - /// Validates that arguments requiring specific flags are used correctly. - /// Provides helpful error messages when users provide file/directory arguments without proper flags. - /// - /// 0 if validation passes, non-zero error code if validation fails - private static int ValidateArgumentsForRequiredFlags(string[] args) - { - foreach (string arg in args) - { - if (arg.StartsWith("-")) - { - // Skip options/flags - continue; - } - - string? errorMessage = null; - string? suggestedUsage = null; - - // Check for .sln files - if (arg.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) && File.Exists(arg)) - { - errorMessage = $"Solution file '{arg}' was provided as a positional argument."; - suggestedUsage = $"Consider passing the solution as the default target by running: dotnet test (from the solution directory)\n" + - $"Or use the new Testing Platform with: --solution {arg}\n" + - "To enable Testing Platform, create a 'dotnet.config' file with:\n" + - "[dotnet.test.runner]\n" + - "name = Microsoft.Testing.Platform"; - } - // Check for .csproj/.vbproj/.fsproj files - else if ((arg.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || - arg.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) || - arg.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase)) && File.Exists(arg)) - { - errorMessage = $"Project file '{arg}' was provided as a positional argument."; - suggestedUsage = $"Consider passing the project as the default target by running: dotnet test (from the project directory)\n" + - $"Or use the new Testing Platform with: --project {arg}\n" + - "To enable Testing Platform, create a 'dotnet.config' file with:\n" + - "[dotnet.test.runner]\n" + - "name = Microsoft.Testing.Platform"; - } - // Check for directories (if they exist) - else if (Directory.Exists(arg)) - { - errorMessage = $"Directory '{arg}' was provided as a positional argument."; - suggestedUsage = $"Use the new Testing Platform with: --directory {arg}\n" + - "To enable Testing Platform, create a 'dotnet.config' file with:\n" + - "[dotnet.test.runner]\n" + - "name = Microsoft.Testing.Platform"; - } - // Check for .dll or .exe files (but not for VSTest forwarding case) - else if ((arg.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || - arg.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && - File.Exists(arg)) - { - errorMessage = $"Test assembly '{arg}' was provided as a positional argument."; - suggestedUsage = $"Use the new Testing Platform with: --test-modules {arg}\n" + - "To enable Testing Platform, create a 'dotnet.config' file with:\n" + - "[dotnet.test.runner]\n" + - "name = Microsoft.Testing.Platform"; - } - - if (errorMessage != null && suggestedUsage != null) - { - Reporter.Error.WriteLine(errorMessage); - Reporter.Error.WriteLine(suggestedUsage); - Reporter.Error.WriteLine("\nFor more information about the available options, run 'dotnet test --help'."); - return 1; - } - } - - return 0; - } } public class TerminalLoggerDetector From c915df9f815cf4b9eff3d726566141a3756fc5cd Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 8 Aug 2025 18:11:29 +0200 Subject: [PATCH 5/9] Cleanup --- .../dotnet/Commands/CliCommandStrings.resx | 14 +++- .../Commands/Test/TestingPlatformCommand.cs | 72 +------------------ .../dotnet/Commands/Test/ValidationUtility.cs | 42 +++++++++++ .../Commands/xlf/CliCommandStrings.cs.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.de.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.es.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.fr.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.it.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.ja.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.ko.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.pl.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.pt-BR.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.ru.xlf | 20 ++++++ .../Commands/xlf/CliCommandStrings.tr.xlf | 20 ++++++ .../xlf/CliCommandStrings.zh-Hans.xlf | 20 ++++++ .../xlf/CliCommandStrings.zh-Hant.xlf | 20 ++++++ 16 files changed, 317 insertions(+), 71 deletions(-) diff --git a/src/Cli/dotnet/Commands/CliCommandStrings.resx b/src/Cli/dotnet/Commands/CliCommandStrings.resx index 2a62ba8ec28d..6696c5cda22c 100644 --- a/src/Cli/dotnet/Commands/CliCommandStrings.resx +++ b/src/Cli/dotnet/Commands/CliCommandStrings.resx @@ -2605,4 +2605,16 @@ Proceed? Tool package download needs confirmation. Run in interactive mode or use the "--yes" command-line option to confirm. {Locked="--yes"} - + + Specifying a solution for 'dotnet test' should be via '--solution'. + + + Specifying a project for 'dotnet test' should be via '--project'. + + + Specifying a directory for 'dotnet test' should be via '--directory'. + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + \ No newline at end of file diff --git a/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs b/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs index 28a8aa78be2f..e30feb765d8c 100644 --- a/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs +++ b/src/Cli/dotnet/Commands/Test/TestingPlatformCommand.cs @@ -46,14 +46,8 @@ public int Run(ParseResult parseResult) private int RunInternal(ParseResult parseResult) { ValidationUtility.ValidateMutuallyExclusiveOptions(parseResult); - - // Validate arguments for required flags - var validationResult = ValidateArgumentsForRequiredFlags(parseResult); - if (validationResult != 0) - { - return validationResult; - } - + ValidationUtility.ValidateSolutionOrProjectOrDirectoryOrModulesArePassedCorrectly(parseResult); + PrepareEnvironment(parseResult, out TestOptions testOptions, out int degreeOfParallelism); InitializeOutput(degreeOfParallelism, parseResult, testOptions.IsHelp); @@ -213,66 +207,4 @@ private void CleanUp() { _eventHandlers?.Dispose(); } - - /// - /// Validates that arguments requiring specific flags are used correctly for Microsoft Testing Platform. - /// Provides helpful error messages when users provide file/directory arguments without proper flags. - /// - /// 0 if validation passes, non-zero error code if validation fails - private static int ValidateArgumentsForRequiredFlags(ParseResult parseResult) - { - // Check unmatched tokens for file/directory arguments that should use flags - var unmatchedTokens = parseResult.UnmatchedTokens.ToList(); - - foreach (string token in unmatchedTokens) - { - if (token.StartsWith("-")) - { - // Skip options/flags - continue; - } - - string errorMessage = null; - string suggestedUsage = null; - - // Check for .sln files - if (token.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) && File.Exists(token)) - { - errorMessage = $"Solution file '{token}' was provided as a positional argument."; - suggestedUsage = $"Use the --solution flag: dotnet test --solution {token}"; - } - // Check for .csproj/.vbproj/.fsproj files - else if ((token.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || - token.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) || - token.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase)) && File.Exists(token)) - { - errorMessage = $"Project file '{token}' was provided as a positional argument."; - suggestedUsage = $"Use the --project flag: dotnet test --project {token}"; - } - // Check for directories (if they exist) - else if (Directory.Exists(token)) - { - errorMessage = $"Directory '{token}' was provided as a positional argument."; - suggestedUsage = $"Use the --directory flag: dotnet test --directory {token}"; - } - // Check for .dll or .exe files - else if ((token.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || - token.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && - File.Exists(token)) - { - errorMessage = $"Test assembly '{token}' was provided as a positional argument."; - suggestedUsage = $"Use the --test-modules flag: dotnet test --test-modules {token}"; - } - - if (errorMessage != null && suggestedUsage != null) - { - Reporter.Error.WriteLine(errorMessage); - Reporter.Error.WriteLine(suggestedUsage); - Reporter.Error.WriteLine("\nFor more information about the available options, run 'dotnet test --help'."); - return 1; - } - } - - return 0; - } } diff --git a/src/Cli/dotnet/Commands/Test/ValidationUtility.cs b/src/Cli/dotnet/Commands/Test/ValidationUtility.cs index 105e092e4725..c871933fb5dd 100644 --- a/src/Cli/dotnet/Commands/Test/ValidationUtility.cs +++ b/src/Cli/dotnet/Commands/Test/ValidationUtility.cs @@ -53,6 +53,7 @@ static void ValidateOptionsIrrelevantToModulesFilter(ParseResult parseResult) } } } + public static bool ValidateBuildPathOptions(BuildOptions buildPathOptions, TerminalTestReporter output) { PathOptions pathOptions = buildPathOptions.PathOptions; @@ -76,6 +77,47 @@ public static bool ValidateBuildPathOptions(BuildOptions buildPathOptions, Termi return true; } + /// + /// Validates that arguments requiring specific command-line switches are used correctly for Microsoft.Testing.Platform. + /// Provides helpful error messages when users provide file/directory arguments without proper switches. + /// + public static void ValidateSolutionOrProjectOrDirectoryOrModulesArePassedCorrectly(ParseResult parseResult) + { + if (Environment.GetEnvironmentVariable("DOTNET_TEST_DISABLE_SWITCH_VALIDATION") is "true" or "1") + { + // In case there is a valid case, users can opt-out. + // Note that the validation here is added to have a "better" error message for scenarios that will already fail. + // So, disabling validation is okay if the user scenario is valid. + return; + } + + foreach (string token in parseResult.UnmatchedTokens) + { + // Check for .sln files + if ((token.EndsWith(".sln", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".slnx", StringComparison.OrdinalIgnoreCase)) && File.Exists(token)) + { + throw new GracefulException(CliCommandStrings.TestCommandUseSolution); + } + else if ((token.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".vbproj", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".fsproj", StringComparison.OrdinalIgnoreCase)) && File.Exists(token)) + { + throw new GracefulException(CliCommandStrings.TestCommandUseProject); + } + else if (Directory.Exists(token)) + { + throw new GracefulException(CliCommandStrings.TestCommandUseDirectory); + } + else if ((token.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || + token.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) && + File.Exists(token)) + { + throw new GracefulException(CliCommandStrings.TestCommandUseTestModules); + } + } + } + private static bool ValidateSolutionFilePath(string filePath, TerminalTestReporter output) { if (!CliConstants.SolutionExtensions.Contains(Path.GetExtension(filePath))) diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf index 64a073d7c81c..6be7d4abcabb 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf @@ -3015,6 +3015,26 @@ Cílem projektu je více architektur. Pomocí parametru {0} určete, která arch OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Konfigurace, která se má použít pro spuštění testů. Výchozí možností pro většinu projektů je Debug. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf index 109c182e2e04..0f6f1680e123 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf @@ -3015,6 +3015,26 @@ Ihr Projekt verwendet mehrere Zielframeworks. Geben Sie über "{0}" an, welches OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Die für die Testausführung zu verwendende Konfiguration. Standard für die meisten Projekte ist "Debug". diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf index 4b52ce438a03..7f9e065467fe 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf @@ -3015,6 +3015,26 @@ Su proyecto tiene como destino varias plataformas. Especifique la que quiere usa OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. La configuración que se usará para ejecutar pruebas. El valor predeterminado para la mayoría de los proyectos es "Debug". diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf index b82c108765ca..32c6026a45de 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf @@ -3015,6 +3015,26 @@ Votre projet cible plusieurs frameworks. Spécifiez le framework à exécuter à OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Configuration à utiliser pour l'exécution des tests. La valeur par défaut pour la plupart des projets est 'Debug'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf index 36ce6c7bf784..655baed11c72 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf @@ -3015,6 +3015,26 @@ Il progetto è destinato a più framework. Specificare il framework da eseguire OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Configurazione da usare per eseguire i test. L'impostazione predefinita per la maggior parte dei progetti è 'Debug'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf index ec5845275adf..748d60a4c3d0 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf @@ -3015,6 +3015,26 @@ Your project targets multiple frameworks. Specify which framework to run using ' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. テストの実行に使用する構成。ほとんどのプロジェクトで、既定値は 'Debug' です。 diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf index 24a33bd40fbe..4d8775ba5f03 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf @@ -3015,6 +3015,26 @@ Your project targets multiple frameworks. Specify which framework to run using ' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. 테스트 실행에 사용할 구성입니다. 대부분의 프로젝트에서 기본값은 'Debug'입니다. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf index 3ab929146205..af8803d28357 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf @@ -3015,6 +3015,26 @@ Projekt ma wiele platform docelowych. Określ platformę do uruchomienia przy u OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Konfiguracja do użycia na potrzeby uruchamiania testów. W przypadku większości projektów ustawienie domyślne to „Debugowanie”. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf index c2d3b8d5b224..3c6ace0ebe45 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf @@ -3015,6 +3015,26 @@ Ele tem diversas estruturas como destino. Especifique que estrutura executar usa OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. A configuração a ser usada para executar testes. O padrão para a maioria dos projetos é 'Debug'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf index 1b9fb6f85c3c..f085d8722476 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf @@ -3015,6 +3015,26 @@ Your project targets multiple frameworks. Specify which framework to run using ' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Конфигурация для выполнения тестов. По умолчанию для большинства проектов используется "Debug". diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf index 9009d605ee54..ab7e3340dced 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf @@ -3015,6 +3015,26 @@ Projeniz birden fazla Framework'ü hedefliyor. '{0}' kullanarak hangi Framework' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. Testleri çalıştırmak için kullanılacak yapılandırma. Çoğu proje için varsayılan, ‘Hata Ayıklama’ seçeneğidir. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf index f0de7d31f629..2a7df041cefb 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf @@ -3015,6 +3015,26 @@ Your project targets multiple frameworks. Specify which framework to run using ' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. 用于运行测试的配置。大多数项目的默认值是 "Debug"。 diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf index 6b6ec748e046..1f8b7deb6ff0 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf @@ -3015,6 +3015,26 @@ Your project targets multiple frameworks. Specify which framework to run using ' OUTPUT_DIR + + Specifying a directory for 'dotnet test' should be via '--directory'. + Specifying a directory for 'dotnet test' should be via '--directory'. + + + + Specifying a project for 'dotnet test' should be via '--project'. + Specifying a project for 'dotnet test' should be via '--project'. + + + + Specifying a solution for 'dotnet test' should be via '--solution'. + Specifying a solution for 'dotnet test' should be via '--solution'. + + + + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + + The configuration to use for running tests. The default for most projects is 'Debug'. 要用於執行測試的組態。大部分的專案預設為「偵錯」。 From efa5c92d11474e7a8e04e3285aa078499dfb1533 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 8 Aug 2025 18:21:42 +0200 Subject: [PATCH 6/9] Cleanup --- .../Test/TestCommandParserTests.cs | 1 - .../Test/TestCommandValidationTests.cs | 149 ++++-------------- 2 files changed, 28 insertions(+), 122 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs index c202348b7865..9b86d3c92c4c 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs @@ -5,7 +5,6 @@ using System.CommandLine; using Microsoft.DotNet.Cli.Commands.Test; -using Microsoft.DotNet.Cli; namespace Microsoft.DotNet.Cli.Test.Tests { diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs index ac9ad30ff7aa..92a84c1fd51c 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs @@ -12,10 +12,10 @@ public TestCommandValidationTests(ITestOutputHelper log) : base(log) } [Theory] - [InlineData("MySolution.sln", "Solution file 'MySolution.sln' was provided as a positional argument.")] - [InlineData("MyProject.csproj", "Project file 'MyProject.csproj' was provided as a positional argument.")] - [InlineData("MyProject.vbproj", "Project file 'MyProject.vbproj' was provided as a positional argument.")] - [InlineData("MyProject.fsproj", "Project file 'MyProject.fsproj' was provided as a positional argument.")] + [InlineData("MySolution.sln", "Specifying a solution for 'dotnet test' should be via '--solution'.")] + [InlineData("MyProject.csproj", "Specifying a project for 'dotnet test' should be via '--project'.")] + [InlineData("MyProject.vbproj", "Specifying a project for 'dotnet test' should be via '--project'.")] + [InlineData("MyProject.fsproj", "Specifying a project for 'dotnet test' should be via '--project'.")] public void TestCommandShouldValidateFileArgumentsAndProvideHelpfulMessages(string filename, string expectedErrorStart) { var testDir = _testAssetsManager.CreateTestDirectory(); @@ -23,15 +23,18 @@ public void TestCommandShouldValidateFileArgumentsAndProvideHelpfulMessages(stri // Create the test file var testFilePath = Path.Combine(testDir.Path, filename); File.WriteAllText(testFilePath, "dummy content"); + File.WriteAllText(Path.Combine(testDir.Path, "dotnet.config"), + """ + [dotnet.test.runner] + name = Microsoft.Testing.Platform + """); - var result = new DotnetTestCommand(Log, disableNewOutput: true) + var result = new DotnetTestCommand(Log, disableNewOutput: false) .WithWorkingDirectory(testDir.Path) .Execute(filename); - result.ExitCode.Should().Be(1); + result.ExitCode.Should().NotBe(0); result.StdErr.Should().Contain(expectedErrorStart); - result.StdErr.Should().Contain("Testing Platform"); - result.StdErr.Should().Contain("dotnet.config"); } [Fact] @@ -40,15 +43,18 @@ public void TestCommandShouldValidateDirectoryArgumentAndProvideHelpfulMessage() var testDir = _testAssetsManager.CreateTestDirectory(); var subDir = Path.Combine(testDir.Path, "test_directory"); Directory.CreateDirectory(subDir); + File.WriteAllText(Path.Combine(testDir.Path, "dotnet.config"), + """ + [dotnet.test.runner] + name = Microsoft.Testing.Platform + """); - var result = new DotnetTestCommand(Log, disableNewOutput: true) + var result = new DotnetTestCommand(Log, disableNewOutput: false) .WithWorkingDirectory(testDir.Path) .Execute("test_directory"); - result.ExitCode.Should().Be(1); - result.StdErr.Should().Contain("Directory 'test_directory' was provided as a positional argument."); - result.StdErr.Should().Contain("--directory test_directory"); - result.StdErr.Should().Contain("Testing Platform"); + result.ExitCode.Should().NotBe(0); + result.StdErr.Should().Contain("Specifying a directory for 'dotnet test' should be via '--directory'."); } [Fact] @@ -59,117 +65,18 @@ public void TestCommandShouldValidateDllArgumentAndProvideHelpfulMessage() // Create a dummy dll file var dllPath = Path.Combine(testDir.Path, "test.dll"); File.WriteAllText(dllPath, "dummy dll content"); + File.WriteAllText(Path.Combine(testDir.Path, "dotnet.config"), + """ + [dotnet.test.runner] + name = Microsoft.Testing.Platform + """); - var result = new DotnetTestCommand(Log, disableNewOutput: true) + var result = new DotnetTestCommand(Log, disableNewOutput: false) .WithWorkingDirectory(testDir.Path) .Execute("test.dll"); - result.ExitCode.Should().Be(1); - result.StdErr.Should().Contain("Test assembly 'test.dll' was provided as a positional argument."); - result.StdErr.Should().Contain("--test-modules test.dll"); - result.StdErr.Should().Contain("Testing Platform"); - } - - [Fact] - public void TestCommandShouldAllowNormalOptionsWithoutValidation() - { - var testDir = _testAssetsManager.CreateTestDirectory(); - - // Test that normal options like --help still work without triggering validation - var result = new DotnetTestCommand(Log, disableNewOutput: true) - .Execute("--help"); - - result.ExitCode.Should().Be(0); - result.StdOut.Should().Contain("Usage:"); - result.StdOut.Should().Contain("dotnet test"); - } - - [Fact] - public void TestCommandShouldNotValidateNonExistentFiles() - { - var testDir = _testAssetsManager.CreateTestDirectory(); - - // Test that non-existent files with project extensions don't trigger validation - var result = new DotnetTestCommand(Log, disableNewOutput: true) - .WithWorkingDirectory(testDir.Path) - .Execute("NonExistent.csproj"); - - // This should pass through to MSBuild and give a different error, not our validation error - result.ExitCode.Should().Be(1); - result.StdErr.Should().NotContain("was provided as a positional argument"); - result.StdErr.Should().NotContain("Testing Platform"); - } - - [Theory] - [InlineData("MySolution.sln", "Solution file 'MySolution.sln' was provided as a positional argument.", "--solution MySolution.sln")] - [InlineData("MyProject.csproj", "Project file 'MyProject.csproj' was provided as a positional argument.", "--project MyProject.csproj")] - [InlineData("MyProject.vbproj", "Project file 'MyProject.vbproj' was provided as a positional argument.", "--project MyProject.vbproj")] - [InlineData("MyProject.fsproj", "Project file 'MyProject.fsproj' was provided as a positional argument.", "--project MyProject.fsproj")] - public void TestCommandWithMTPShouldValidateFileArgumentsAndProvideDirectGuidance(string filename, string expectedErrorStart, string expectedSuggestion) - { - var testDir = _testAssetsManager.CreateTestDirectory(); - - // Create dotnet.config to enable MTP - var configPath = Path.Combine(testDir.Path, "dotnet.config"); - File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); - - // Create the test file - var testFilePath = Path.Combine(testDir.Path, filename); - File.WriteAllText(testFilePath, "dummy content"); - - var result = new DotnetTestCommand(Log, disableNewOutput: true) - .WithWorkingDirectory(testDir.Path) - .Execute(filename); - - result.ExitCode.Should().Be(1); - result.StdErr.Should().Contain(expectedErrorStart); - result.StdErr.Should().Contain(expectedSuggestion); - result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled, so no need to suggest enabling it - } - - [Fact] - public void TestCommandWithMTPShouldValidateDirectoryArgumentAndProvideDirectGuidance() - { - var testDir = _testAssetsManager.CreateTestDirectory(); - - // Create dotnet.config to enable MTP - var configPath = Path.Combine(testDir.Path, "dotnet.config"); - File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); - - var subDir = Path.Combine(testDir.Path, "test_directory"); - Directory.CreateDirectory(subDir); - - var result = new DotnetTestCommand(Log, disableNewOutput: true) - .WithWorkingDirectory(testDir.Path) - .Execute("test_directory"); - - result.ExitCode.Should().Be(1); - result.StdErr.Should().Contain("Directory 'test_directory' was provided as a positional argument."); - result.StdErr.Should().Contain("--directory test_directory"); - result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled - } - - [Fact] - public void TestCommandWithMTPShouldValidateDllArgumentAndProvideDirectGuidance() - { - var testDir = _testAssetsManager.CreateTestDirectory(); - - // Create dotnet.config to enable MTP - var configPath = Path.Combine(testDir.Path, "dotnet.config"); - File.WriteAllText(configPath, "[dotnet.test.runner]\nname = Microsoft.Testing.Platform"); - - // Create a dummy dll file - var dllPath = Path.Combine(testDir.Path, "test.dll"); - File.WriteAllText(dllPath, "dummy dll content"); - - var result = new DotnetTestCommand(Log, disableNewOutput: true) - .WithWorkingDirectory(testDir.Path) - .Execute("test.dll"); - - result.ExitCode.Should().Be(1); - result.StdErr.Should().Contain("Test assembly 'test.dll' was provided as a positional argument."); - result.StdErr.Should().Contain("--test-modules test.dll"); - result.StdErr.Should().NotContain("dotnet.config"); // MTP is already enabled + result.ExitCode.Should().NotBe(0); + result.StdErr.Should().Contain("Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'."); } } -} \ No newline at end of file +} From 480aa2b12007db3db6b81a7b1f646f718c3001ab Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Fri, 8 Aug 2025 18:23:23 +0200 Subject: [PATCH 7/9] Assert english strings only when non-localized --- .../Test/TestCommandValidationTests.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs index 92a84c1fd51c..e2ff70ba8904 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs @@ -34,7 +34,10 @@ public void TestCommandShouldValidateFileArgumentsAndProvideHelpfulMessages(stri .Execute(filename); result.ExitCode.Should().NotBe(0); - result.StdErr.Should().Contain(expectedErrorStart); + if (!TestContext.IsLocalized()) + { + result.StdErr.Should().Contain(expectedErrorStart); + } } [Fact] @@ -54,7 +57,10 @@ public void TestCommandShouldValidateDirectoryArgumentAndProvideHelpfulMessage() .Execute("test_directory"); result.ExitCode.Should().NotBe(0); - result.StdErr.Should().Contain("Specifying a directory for 'dotnet test' should be via '--directory'."); + if (!TestContext.IsLocalized()) + { + result.StdErr.Should().Contain("Specifying a directory for 'dotnet test' should be via '--directory'."); + } } [Fact] @@ -76,7 +82,10 @@ public void TestCommandShouldValidateDllArgumentAndProvideHelpfulMessage() .Execute("test.dll"); result.ExitCode.Should().NotBe(0); - result.StdErr.Should().Contain("Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'."); + if (!TestContext.IsLocalized()) + { + result.StdErr.Should().Contain("Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'."); + } } } } From 5d6eab3738a78e527f7ff4f1bf6711fc41bbf86d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 9 Aug 2025 03:30:13 +0000 Subject: [PATCH 8/9] Fix grammar error: change "Specifying a dlls" to "Specifying dlls" in .resx and .xlf files Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com> --- src/Cli/dotnet/Commands/CliCommandStrings.resx | 2 +- src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf | 4 ++-- src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf | 4 ++-- 14 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Cli/dotnet/Commands/CliCommandStrings.resx b/src/Cli/dotnet/Commands/CliCommandStrings.resx index 6696c5cda22c..d55250fa74cc 100644 --- a/src/Cli/dotnet/Commands/CliCommandStrings.resx +++ b/src/Cli/dotnet/Commands/CliCommandStrings.resx @@ -2615,6 +2615,6 @@ Proceed? Specifying a directory for 'dotnet test' should be via '--directory'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. \ No newline at end of file diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf index 6be7d4abcabb..8fb72716f360 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf @@ -3031,8 +3031,8 @@ Cílem projektu je více architektur. Pomocí parametru {0} určete, která arch - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf index 0f6f1680e123..614f11f3bb92 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf @@ -3031,8 +3031,8 @@ Ihr Projekt verwendet mehrere Zielframeworks. Geben Sie über "{0}" an, welches - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf index 7f9e065467fe..67750aa10927 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf @@ -3031,8 +3031,8 @@ Su proyecto tiene como destino varias plataformas. Especifique la que quiere usa - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf index 32c6026a45de..ed1287261435 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf @@ -3031,8 +3031,8 @@ Votre projet cible plusieurs frameworks. Spécifiez le framework à exécuter à - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf index 655baed11c72..1701ebd139e3 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf @@ -3031,8 +3031,8 @@ Il progetto è destinato a più framework. Specificare il framework da eseguire - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf index 748d60a4c3d0..f2dc148710f1 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf @@ -3031,8 +3031,8 @@ Your project targets multiple frameworks. Specify which framework to run using ' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf index 4d8775ba5f03..d4f4a6cf2c4f 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf @@ -3031,8 +3031,8 @@ Your project targets multiple frameworks. Specify which framework to run using ' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf index af8803d28357..c182bac522b2 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf @@ -3031,8 +3031,8 @@ Projekt ma wiele platform docelowych. Określ platformę do uruchomienia przy u - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf index 3c6ace0ebe45..0ccffd065bf7 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf @@ -3031,8 +3031,8 @@ Ele tem diversas estruturas como destino. Especifique que estrutura executar usa - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf index f085d8722476..8d99de7d1a82 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf @@ -3031,8 +3031,8 @@ Your project targets multiple frameworks. Specify which framework to run using ' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf index ab7e3340dced..3adba7705d9c 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf @@ -3031,8 +3031,8 @@ Projeniz birden fazla Framework'ü hedefliyor. '{0}' kullanarak hangi Framework' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf index 2a7df041cefb..b2e5dbe36071 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf @@ -3031,8 +3031,8 @@ Your project targets multiple frameworks. Specify which framework to run using ' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. diff --git a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf index 1f8b7deb6ff0..44eb22e97724 100644 --- a/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf +++ b/src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf @@ -3031,8 +3031,8 @@ Your project targets multiple frameworks. Specify which framework to run using ' - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. - Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. + Specifying dlls or executables for 'dotnet test' should be via '--test-modules'. From 74f59938b8b638fe413e0d53c0e8121d33a33213 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Mon, 11 Aug 2025 09:15:54 +0200 Subject: [PATCH 9/9] Update TestCommandValidationTests.cs --- .../CommandTests/Test/TestCommandValidationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs index e2ff70ba8904..52faf4ced86b 100644 --- a/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs +++ b/test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs @@ -84,7 +84,7 @@ public void TestCommandShouldValidateDllArgumentAndProvideHelpfulMessage() result.ExitCode.Should().NotBe(0); if (!TestContext.IsLocalized()) { - result.StdErr.Should().Contain("Specifying a dlls or executables for 'dotnet test' should be via '--test-modules'."); + result.StdErr.Should().Contain("Specifying dlls or executables for 'dotnet test' should be via '--test-modules'."); } } }