Adding try catch for xunit test to get logs
This commit is contained in:
parent
061722d4ad
commit
9b92fe2336
1 changed files with 26 additions and 7 deletions
|
@ -92,15 +92,34 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
||||||
.WithWorkingDirectory(testProjectDirectory)
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
.ExecuteWithCapturedOutput();
|
.ExecuteWithCapturedOutput();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 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");
|
||||||
|
|
||||||
// Verify
|
// for target framework netcoreapp1.0
|
||||||
// for target framework net46
|
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
|
||||||
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
|
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
|
||||||
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTestDesktop");
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("*********************************Xunit StdOut****************************************************************");
|
||||||
|
Console.WriteLine(result.StdOut.ToString());
|
||||||
|
|
||||||
// for target framework netcoreapp1.0
|
Console.WriteLine("*********************************Xunit StdErr****************************************************************");
|
||||||
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
|
Console.WriteLine(result.StdErr.ToString());
|
||||||
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
|
|
||||||
|
string logfile1 = Path.Combine(testProjectDirectory, "LogFile.txt");
|
||||||
|
string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile.host.*");
|
||||||
|
|
||||||
|
Console.WriteLine("**********************************Xunit Vstest.console Log****************************************************************");
|
||||||
|
Console.WriteLine(File.ReadAllText(logfile1));
|
||||||
|
Console.WriteLine("**********************************Xunit TestHost Log****************************************************************");
|
||||||
|
Console.WriteLine(logfile2.Length > 0 ? File.ReadAllText(logfile2[0]) : "No log file found");
|
||||||
|
Console.WriteLine("**************************************************************************************************");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue