暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ResultsSavingCallbacks.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.IO;
  3. using UnityEditor.TestTools.TestRunner.Api;
  4. using UnityEditor.Utils;
  5. using UnityEngine;
  6. namespace UnityEditor.TestTools.TestRunner.CommandLineTest
  7. {
  8. [Serializable]
  9. internal class ResultsSavingCallbacks : ScriptableObject, ICallbacks
  10. {
  11. [SerializeField]
  12. public string m_ResultFilePath;
  13. public ResultsSavingCallbacks()
  14. {
  15. m_ResultFilePath = GetDefaultResultFilePath();
  16. }
  17. public void RunStarted(ITestAdaptor testsToRun)
  18. {
  19. }
  20. public virtual void RunFinished(ITestResultAdaptor testResults)
  21. {
  22. if (string.IsNullOrEmpty(m_ResultFilePath))
  23. {
  24. m_ResultFilePath = GetDefaultResultFilePath();
  25. }
  26. TestRunnerApi.SaveResultToFile(testResults, m_ResultFilePath);
  27. }
  28. public void TestStarted(ITestAdaptor test)
  29. {
  30. }
  31. public void TestFinished(ITestResultAdaptor result)
  32. {
  33. }
  34. private static string GetDefaultResultFilePath()
  35. {
  36. var fileName = "TestResults-" + DateTime.Now.Ticks + ".xml";
  37. var projectPath = Directory.GetCurrentDirectory();
  38. return Paths.Combine(projectPath, fileName);
  39. }
  40. }
  41. }