Reduced the test name to overcome 256 character file length limit in windows

This commit is contained in:
Faizan Ahmad 2016-11-02 23:38:20 +05:30
parent dc249a94e9
commit 111499899d
12 changed files with 20 additions and 70 deletions

View file

@ -12,15 +12,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests
{ {
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
{ {
// Adding log to root cause test failure for net46
private const string vstestLog = "VSTEST_TRACE_BUILD";
// project targeting net46 will not run in non windows machine. // project targeting net46 will not run in non windows machine.
[WindowsOnlyFact] [WindowsOnlyFact]
public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM() public void MStestMultiTFM()
{ {
Environment.SetEnvironmentVariable(vstestLog, "1");
// Copy VSTestDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests // Copy VSTestDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests
string testAppName = "VSTestDesktopAndNetCoreApp"; string testAppName = "VSTestDesktopAndNetCoreApp";
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName); TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
@ -37,12 +32,9 @@ namespace Microsoft.DotNet.Cli.Test.Tests
// Call test // Call test
CommandResult result = new DotnetTestCommand() CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(testProjectDirectory) .WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput("--diag LogFile.txt"); .ExecuteWithCapturedOutput();
try
{
// Verify // Verify
// for target framework net46 // for target framework net46
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0."); result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
@ -52,29 +44,9 @@ namespace Microsoft.DotNet.Cli.Test.Tests
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0."); result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp"); result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp");
} }
catch
{
Console.WriteLine("*********************************StdOut****************************************************************");
Console.WriteLine(result.StdOut.ToString());
Console.WriteLine("*********************************StdErr****************************************************************");
Console.WriteLine(result.StdErr.ToString());
string logfile1 = Path.Combine(testProjectDirectory, "LogFile.txt");
string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile.host.*");
Console.WriteLine("**********************************Vstest.console Log****************************************************************");
Console.WriteLine(File.ReadAllText(logfile1));
Console.WriteLine("**********************************TestHost Log1****************************************************************");
Console.WriteLine(logfile2.Length > 0 ? File.ReadAllText(logfile2[0]) : "No log file found");
Console.WriteLine("**********************************TestHost Log2****************************************************************");
Console.WriteLine(logfile2.Length > 1 ? File.ReadAllText(logfile2[1]) : "No log file found");
Console.WriteLine("**************************************************************************************************");
}
}
[WindowsOnlyFact] [WindowsOnlyFact]
public void TestsFromAGivenXunitProjectShouldRunWithExpectedOutputForMultiTFM() public void XunitMultiTFM()
{ {
// Copy VSTestXunitDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests // Copy VSTestXunitDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests
string testAppName = "VSTestXunitDesktopAndNetCoreApp"; string testAppName = "VSTestXunitDesktopAndNetCoreApp";
@ -92,10 +64,8 @@ namespace Microsoft.DotNet.Cli.Test.Tests
// Call test // Call test
CommandResult result = new DotnetTestCommand() CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(testProjectDirectory) .WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput("--diag LogFile2.txt"); .ExecuteWithCapturedOutput();
try
{
// Verify // Verify
// for target framework net46 // for target framework net46
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0."); result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
@ -105,25 +75,5 @@ namespace Microsoft.DotNet.Cli.Test.Tests
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0."); result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp"); result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
} }
catch
{
Console.WriteLine("*********************************Xunit StdOut****************************************************************");
Console.WriteLine(result.StdOut.ToString());
Console.WriteLine("*********************************Xunit StdErr****************************************************************");
Console.WriteLine(result.StdErr.ToString());
string logfile1 = Path.Combine(testProjectDirectory, "LogFile2.txt");
string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile2.host.*");
Console.WriteLine("**********************************Xunit Vstest.console Log****************************************************************");
Console.WriteLine(File.ReadAllText(logfile1));
Console.WriteLine("**********************************Xunit TestHost Log1****************************************************************");
Console.WriteLine(logfile2.Length > 0 ? File.ReadAllText(logfile2[0]) : "No log file found");
Console.WriteLine("**********************************Xunit TestHost Log2****************************************************************");
Console.WriteLine(logfile2.Length > 1 ? File.ReadAllText(logfile2[1]) : "No log file found");
Console.WriteLine("**************************************************************************************************");
}
}
} }
} }

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase
{ {
[Fact] [Fact]
public void TestsFromAGivenProjectShouldRunWithExpectedOutput() public void MSTestSingleTFM()
{ {
// Copy VSTestDotNetCoreProject project in output directory of project dotnet-vstest.Tests // Copy VSTestDotNetCoreProject project in output directory of project dotnet-vstest.Tests
string testAppName = "VSTestDotNetCoreProject"; string testAppName = "VSTestDotNetCoreProject";
@ -41,7 +41,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
} }
[Fact] [Fact]
public void TestsFromAGivenXunitProjectShouldRunWithExpectedOutput() public void XunitSingleTFM()
{ {
// Copy VSTestXunitDotNetCoreProject project in output directory of project dotnet-vstest.Tests // Copy VSTestXunitDotNetCoreProject project in output directory of project dotnet-vstest.Tests
string testAppName = "VSTestXunitDotNetCoreProject"; string testAppName = "VSTestXunitDotNetCoreProject";