Made dotnet-(vs)test.Tests pass on localized setup

This commit is contained in:
Nick Guerrera 2017-06-12 18:32:31 -07:00
parent 023acbd212
commit 981e3ae19c
4 changed files with 83 additions and 31 deletions

View file

@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Globalization;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Tools.Test.Utilities
@ -33,5 +34,18 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
"dotnet");
}
}
public static bool IsLocalized()
{
for (var culture = CultureInfo.CurrentUICulture; !culture.Equals(CultureInfo.InvariantCulture); culture = culture.Parent)
{
if (culture.Name == "en")
{
return false;
}
}
return true;
}
}
}

View file

@ -34,11 +34,14 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.WithRuntime(runtime)
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
result.StdOut
.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.", "because .NET 4.6 tests will pass")
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTestDesktop", "because .NET 4.6 tests will pass")
.And.Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.", "because netcoreapp2.0 tests will fail")
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp", "because netcoreapp2.0 tests will fail");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut
.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.", "because .NET 4.6 tests will pass")
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTestDesktop", "because .NET 4.6 tests will pass")
.And.Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.", "because netcoreapp2.0 tests will fail")
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp", "because netcoreapp2.0 tests will fail");
}
result.ExitCode.Should().Be(1);
}
@ -66,14 +69,19 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
// Verify
// for target framework net46
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTestDesktop");
if (!DotnetUnderTest.IsLocalized())
{
// for target framework net46
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTestDesktop");
// for target framework netcoreapp1.0
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
}
// for target framework netcoreapp1.0
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
result.ExitCode.Should().Be(1);
}
}
}

View file

@ -25,9 +25,13 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
// Verify
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
result.ExitCode.Should().Be(1);
}
@ -45,9 +49,13 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
result.ExitCode.Should().Be(1);
}
@ -92,9 +100,13 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
// Verify
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTest");
}
result.ExitCode.Should().Be(1);
}
@ -114,7 +126,12 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.ExecuteWithCapturedOutput("--no-build");
// Verify
result.StdErr.Should().Contain(expectedError);
if (!DotnetUnderTest.IsLocalized())
{
result.StdErr.Should().Contain(expectedError);
}
result.ExitCode.Should().Be(1);
}
[Fact]
@ -207,9 +224,14 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.WithWorkingDirectory(rootPath)
.ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --no-restore");
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
result.ExitCode.Should().Be(1);
}
[Fact]
@ -224,9 +246,13 @@ namespace Microsoft.DotNet.Cli.Test.Tests
.ExecuteWithCapturedOutput("-v q");
// Verify
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().NotContain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().NotContain("Failed TestNamespace.VSTestTests.VSTestFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().NotContain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().NotContain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
result.ExitCode.Should().Be(1);
}

View file

@ -38,10 +38,14 @@ namespace Microsoft.DotNet.Cli.VSTest.Tests
// Call vstest
var result = new VSTestCommand().ExecuteWithCapturedOutput(argsForVstest);
result.StdOut
.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.")
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTest")
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
if (!DotnetUnderTest.IsLocalized())
{
result.StdOut
.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.")
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTest")
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
result.ExitCode.Should().Be(1);
}
}