diff --git a/RuntimeInternals/ScreenshotHelper.cs b/RuntimeInternals/ScreenshotHelper.cs index 2c47322..e6a2459 100644 --- a/RuntimeInternals/ScreenshotHelper.cs +++ b/RuntimeInternals/ScreenshotHelper.cs @@ -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; } ///