Skip to content

Commit

Permalink
Only attach log files for current test (#17949)
Browse files Browse the repository at this point in the history
Previously we were attaching all log files in the appium log directory,
so failed tests in AzDO had a large number of attachments, most
unrelated to the test at hand. Fix to only attach files for the current
test.
  • Loading branch information
rmarinho committed Oct 12, 2023
2 parents faa7d8a + 8dbf004 commit 40caa02
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/TestUtils/src/UITest.NUnit/UITestBase.cs
Expand Up @@ -118,13 +118,13 @@ void SaveDiagnosticLogs(string? note = null)
{
string name = TestContext.CurrentContext.Test.MethodName ?? TestContext.CurrentContext.Test.Name;

_ = App.Screenshot(Path.Combine(logDir, $"{name}-{_testDevice}{note}ScreenShot"));
File.WriteAllText(Path.Combine(logDir, $"{name}-{_testDevice}{note}PageSource.txt"), App.ElementTree);
}
var screenshotPath = Path.Combine(logDir, $"{name}-{_testDevice}{note}ScreenShot.png");
_ = App.Screenshot(screenshotPath);
TestContext.AddTestAttachment(screenshotPath, Path.GetFileName(screenshotPath));

foreach (var log in Directory.GetFiles(logDir))
{
TestContext.AddTestAttachment(log, Path.GetFileName(log));
var pageSourcePath = Path.Combine(logDir, $"{name}-{_testDevice}{note}PageSource.txt");
File.WriteAllText(pageSourcePath, App.ElementTree);
TestContext.AddTestAttachment(pageSourcePath, Path.GetFileName(pageSourcePath));
}
}
}
Expand Down

0 comments on commit 40caa02

Please sign in to comment.