TestRunnerCallback.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using NUnit.Framework.Interfaces;
  2. using UnityEngine;
  3. using UnityEngine.TestTools.TestRunner;
  4. namespace UnityEditor.TestTools.TestRunner
  5. {
  6. internal class TestRunnerCallback : ScriptableObject, ITestRunnerListener
  7. {
  8. public void RunStarted(ITest testsToRun)
  9. {
  10. EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
  11. }
  12. private void OnPlayModeStateChanged(PlayModeStateChange state)
  13. {
  14. if (state == PlayModeStateChange.ExitingPlayMode)
  15. {
  16. EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
  17. //We need to make sure we don't block NUnit thread in case we exit PlayMode earlier
  18. PlaymodeTestsController.TryCleanup();
  19. }
  20. }
  21. public void RunFinished(ITestResult testResults)
  22. {
  23. EditorApplication.isPlaying = false;
  24. }
  25. public void TestStarted(ITest testName)
  26. {
  27. }
  28. public void TestFinished(ITestResult test)
  29. {
  30. }
  31. }
  32. }