diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs index 88925d7f9..43a7e81bd 100644 --- a/src/dotnet/commands/dotnet-test/Program.cs +++ b/src/dotnet/commands/dotnet-test/Program.cs @@ -26,10 +26,10 @@ namespace Microsoft.DotNet.Tools.Test var dotnetTestParams = new DotnetTestParams(); - dotnetTestParams.Parse(args); - try { + dotnetTestParams.Parse(args); + if (dotnetTestParams.Help) { return 0; diff --git a/test/dotnet-test.Tests/GivenThatWeWantToRunTests.cs b/test/dotnet-test.Tests/GivenThatWeWantToRunTests.cs index 709893840..703243dc4 100644 --- a/test/dotnet-test.Tests/GivenThatWeWantToRunTests.cs +++ b/test/dotnet-test.Tests/GivenThatWeWantToRunTests.cs @@ -25,5 +25,19 @@ namespace Microsoft.Dotnet.Tools.Test.Tests .And .HaveStdErrContaining("dotnet restore"); } + + [Fact] + public void It_fails_correctly_with_invalid_runtime_parameter() + { + var instance = TestAssetsManager.CreateTestInstance(Path.Combine("ProjectsWithTests", "NetCoreAppOnlyProject")); + + new DotnetTestCommand() + .WithLockFiles() + .ExecuteWithCapturedOutput(instance.TestRoot) + .Should() + .Fail() + .And + .HaveStdErrContaining("Missing value for option 'runtime'"); + } } }