Skip to content

Commit

Permalink
Fix screenshot default filename when called out of test context
Browse files Browse the repository at this point in the history
  • Loading branch information
nowsprinting committed May 2, 2024
1 parent f9b3315 commit ca992c3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions RuntimeInternals/ScreenshotHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ public static class ScreenshotHelper
private static string DefaultFilename(string callerMemberName)
{
#if UNITY_INCLUDE_TESTS
return TestContext.CurrentTestExecutionContext.CurrentTest.Name
.Replace('(', '_')
.Replace(')', '_')
.Replace(',', '-')
.Replace("\"", "");
// Note: Same as the file name created under ActualImages of the Graphics Tests Framework package.
#else
return callerMemberName;
if (TestContext.CurrentTestExecutionContext != null)
{
return TestContext.CurrentTestExecutionContext.CurrentTest.Name
.Replace('(', '_')
.Replace(')', '_')
.Replace(',', '-')
.Replace("\"", "");
// Note: Same as the file name created under ActualImages of the Graphics Tests Framework package.
}
#endif
return callerMemberName;
}

/// <summary>
Expand Down

0 comments on commit ca992c3

Please sign in to comment.