Merge pull request #9267 from peterhuene/fix-test-verbosity

Fix incorrect default VSTest verbosity level.
This commit is contained in:
Peter Huene 2018-05-11 23:17:05 -07:00 committed by GitHub
commit 59a27df531
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 4 deletions

View file

@ -35,6 +35,9 @@ namespace Microsoft.DotNet.Cli
.OfType<ForwardedArgument>()
.SelectMany(o => o.Values);
public static IEnumerable<string> ForwardedOptionValues(this AppliedOption command, string alias) =>
(command.ValueOrDefault<ForwardedArgument>(alias)?.Values ?? Array.Empty<string>());
private class ForwardedArgument
{
public ForwardedArgument(params string[] values)

View file

@ -60,11 +60,10 @@ namespace Microsoft.DotNet.Tools.Test
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]}");

View file

@ -110,6 +110,27 @@ namespace Microsoft.DotNet.Cli.Test.Tests
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()
{