in GoogleTestAdapter/Tests.Common/ResultChecker/TrxResultChecker.cs [42:87]
public void RunTestsAndCheckOutput(string typeName, string arguments, string testCaseName)
{
string goldenFile = Path.Combine(_goldenFilesDir,
TestResources.GetGoldenFileName(typeName, testCaseName, ".xml"));
string resultsFile = RunExecutableAndGetResultsFile(arguments);
if (resultsFile == null)
{
goldenFile.AsFileInfo().Should().NotExist("Test run did not produce result trx file, therefore no golden file should exist");
return;
}
string transformedResultFile = TransformResultsFile(resultsFile);
CheckIfFileIsParsable(transformedResultFile);
if (!File.Exists(goldenFile))
{
// ReSharper disable once AssignNullToNotNullAttribute
File.Copy(transformedResultFile, goldenFile, true);
Assert.Inconclusive($"First time this test runs, created golden file - check for correctness! File: {goldenFile}");
}
CheckIfFileIsParsable(goldenFile);
string diffFile;
if (!CompareXmlFiles(goldenFile, transformedResultFile, out diffFile))
{
if (!Directory.Exists(_diffFilesDir))
Directory.CreateDirectory(_diffFilesDir);
string htmlDiffFile = Path.Combine(_diffFilesDir,
TestResources.GetGoldenFileName(typeName, testCaseName, ".html"));
string resultFile = Path.ChangeExtension(htmlDiffFile, ".xml");
string htmlContent = CreateDiffAsHtml(goldenFile, diffFile);
File.WriteAllText(htmlDiffFile, htmlContent);
File.Copy(transformedResultFile, resultFile, true);
if (TestMetadata.OverwriteTestResults && !CiSupport.IsRunningOnBuildServer)
{
File.Copy(transformedResultFile, goldenFile, true);
Assert.Inconclusive($"Updated golden file file:///{goldenFile}, test should now pass");
}
Assert.Fail($@"Files differ, see file:///{htmlDiffFile}");
}
}