diff --git a/build/DependencyVersions.props b/build/DependencyVersions.props index abc39ac02b..356c9f1f92 100644 --- a/build/DependencyVersions.props +++ b/build/DependencyVersions.props @@ -10,29 +10,29 @@ $(MicrosoftBuildPackageVersion) $(MicrosoftBuildPackageVersion) $(MicrosoftBuildPackageVersion) - 10.1.4-rtm-180505-0 + 10.1.4-rtm-180508-0 2.8.1-beta6-62904-04 $(MicrosoftCodeAnalysisCSharpPackageVersion) $(MicrosoftCodeAnalysisCSharpPackageVersion) $(MicrosoftCodeAnalysisCSharpPackageVersion) - 2.1.300-rtm-62905-02 + 2.1.300-rtm-62908-02 $(MicrosoftNETSdkPackageVersion) $(MicrosoftAspNetCoreAppPackageVersion) - 2.1.300-rtm-20180505-1661707 + 2.1.300-rtm-20180508-1667423 $(MicrosoftNETSdkWebPackageVersion) $(MicrosoftNETSdkWebPackageVersion) - 1.0.2-beta3-20180505-1661716 + 1.0.2-beta3-20180508-1667431 $(MicrosoftDotNetCommonItemTemplatesPackageVersion) - 1.0.2-beta3-20180505-1661716 - 1.0.2-beta3-20180505-1661716 + 1.0.2-beta3-20180508-1667431 + 1.0.2-beta3-20180508-1667431 $(MicrosoftTemplateEngineCliPackageVersion) $(MicrosoftTemplateEngineCliPackageVersion) $(MicrosoftTemplateEngineCliPackageVersion) $(MicrosoftTemplateEngineCliPackageVersion) 2.1.0-rtm-26508-02 2.1.0-rtm-26508-02 - 0.1.1-rtm-62905-02 - 1.3.1-alpha-62905-02 + 0.1.1-rtm-62908-03 + 1.3.1-alpha-62908-03 $(MicrosoftDotNetProjectJsonMigrationPackageVersion) 0.2.0-beta-62628-01 4.8.0-preview1.5158 diff --git a/src/dotnet/ArgumentForwardingExtensions.cs b/src/dotnet/ArgumentForwardingExtensions.cs index da4a3cdc93..fb27960947 100644 --- a/src/dotnet/ArgumentForwardingExtensions.cs +++ b/src/dotnet/ArgumentForwardingExtensions.cs @@ -35,6 +35,9 @@ public static IEnumerable OptionValuesToBeForwarded( .OfType() .SelectMany(o => o.Values); + public static IEnumerable ForwardedOptionValues(this AppliedOption command, string alias) => + (command.ValueOrDefault(alias)?.Values ?? Array.Empty()); + private class ForwardedArgument { public ForwardedArgument(params string[] values) diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs index 7fd8103b9b..320aaba020 100644 --- a/src/dotnet/commands/dotnet-test/Program.cs +++ b/src/dotnet/commands/dotnet-test/Program.cs @@ -60,11 +60,10 @@ public static TestCommand FromArgs(string[] args, string msbuildPath = null) msbuildArgs.Add($"-property:VSTestCLIRunSettings=\"{runSettingsArg}\""); } - var verbosityArg = msbuildArgs.LastOrDefault(arg => arg.StartsWith("-verbosity")); - - if (!string.IsNullOrEmpty(verbosityArg)) + var verbosityArg = parsedTest.ForwardedOptionValues("verbosity").SingleOrDefault(); + if (verbosityArg != null) { - var verbosity = verbosityArg.Split(':'); + var verbosity = verbosityArg.Split(':', 2); if (verbosity.Length == 2) { msbuildArgs.Add($"-property:VSTestVerbosity={verbosity[1]}"); diff --git a/src/dotnet/commands/dotnet-test/TestCommandParser.cs b/src/dotnet/commands/dotnet-test/TestCommandParser.cs index 4568e402d5..bab8c1c067 100644 --- a/src/dotnet/commands/dotnet-test/TestCommandParser.cs +++ b/src/dotnet/commands/dotnet-test/TestCommandParser.cs @@ -40,19 +40,19 @@ public static Command Test() => Create.Option( "-a|--test-adapter-path", LocalizableStrings.CmdTestAdapterPathDescription, - Accept.ExactlyOneArgument() + Accept.OneOrMoreArguments() .With(name: LocalizableStrings.CmdTestAdapterPath) - .ForwardAsSingle(o => $"-property:VSTestTestAdapterPath={o.Arguments.Single()}")), + .ForwardAsSingle(o => $"-property:VSTestTestAdapterPath=\"{string.Join(";", o.Arguments)}\"")), Create.Option( "-l|--logger", LocalizableStrings.CmdLoggerDescription, - Accept.ExactlyOneArgument() + Accept.OneOrMoreArguments() .With(name: LocalizableStrings.CmdLoggerOption) .ForwardAsSingle(o => { var loggersString = string.Join(";", GetSemiColonEscapedArgs(o.Arguments)); - return $"-property:VSTestLogger={loggersString}"; + return $"-property:VSTestLogger=\"{loggersString}\""; })), CommonOptions.ConfigurationOption(), CommonOptions.FrameworkOption(), @@ -116,4 +116,4 @@ private static string[] GetSemiColonEscapedArgs(IReadOnlyCollection args return array; } } -} \ No newline at end of file +} diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs index 3b06797aaa..3dbd905080 100644 --- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs +++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs @@ -110,6 +110,27 @@ public void XunitSingleTFM() result.ExitCode.Should().Be(1); } + [Fact] + public void GivenAFailingTestItDisplaysFailureDetails() + { + var testInstance = TestAssets.Get("XunitCore") + .CreateInstance() + .WithSourceFiles(); + + var result = new DotnetTestCommand() + .WithWorkingDirectory(testInstance.Root.FullName) + .ExecuteWithCapturedOutput(); + + result.ExitCode.Should().Be(1); + + if (!DotnetUnderTest.IsLocalized()) + { + result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTest"); + result.StdOut.Should().Contain("Assert.Equal() Failure"); + result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0."); + } + } + [Fact] public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven() { @@ -257,6 +278,39 @@ public void ItUsesVerbosityPassedToDefineVerbosityOfConsoleLoggerOfTheTests() result.ExitCode.Should().Be(1); } + [Fact] + public void ItAcceptsMultipleLoggersAsCliArguments() + { + // Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests + var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("10"); + + string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD"); + + // Delete trxLoggerDirectory if it exist + if (Directory.Exists(trxLoggerDirectory)) + { + Directory.Delete(trxLoggerDirectory, true); + } + + // Call test with logger enable + CommandResult result = new DotnetTestCommand() + .WithWorkingDirectory(testProjectDirectory) + .ExecuteWithCapturedOutput("--logger \"trx;logfilename=custom.trx\" --logger console;verbosity=normal -- RunConfiguration.ResultsDirectory=" + trxLoggerDirectory); + + // Verify + var trxFilePath = Path.Combine(trxLoggerDirectory, "custom.trx"); + Assert.True(File.Exists(trxFilePath)); + result.StdOut.Should().Contain(trxFilePath); + result.StdOut.Should().Contain("Passed VSTestPassTest"); + result.StdOut.Should().Contain("Failed VSTestFailTest"); + + // Cleanup trxLoggerDirectory if it exist + if (Directory.Exists(trxLoggerDirectory)) + { + Directory.Delete(trxLoggerDirectory, true); + } + } + private string CopyAndRestoreVSTestDotNetCoreTestApp([CallerMemberName] string callingMethod = "") { // Copy VSTestCore project in output directory of project dotnet-vstest.Tests