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

TestActionCommand.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Reflection;
  5. using NUnit.Framework;
  6. using NUnit.Framework.Internal;
  7. using NUnit.Framework.Internal.Commands;
  8. using UnityEngine.TestRunner.NUnitExtensions.Runner;
  9. namespace UnityEngine.TestTools
  10. {
  11. internal class TestActionCommand : BeforeAfterTestCommandBase<ITestAction>
  12. {
  13. private static readonly Dictionary<MethodInfo, List<ITestAction>> m_TestActionsCache = new Dictionary<MethodInfo, List<ITestAction>>();
  14. public TestActionCommand(TestCommand innerCommand)
  15. : base(innerCommand, "BeforeTest", "AfterTest")
  16. {
  17. if (Test.TypeInfo.Type != null)
  18. {
  19. BeforeActions = GetTestActions(m_TestActionsCache, Test.Method.MethodInfo);
  20. AfterActions = BeforeActions;
  21. }
  22. }
  23. protected override bool AllowFrameSkipAfterAction(ITestAction action)
  24. {
  25. return false;
  26. }
  27. protected override IEnumerator InvokeBefore(ITestAction action, Test test, UnityTestExecutionContext context)
  28. {
  29. action.BeforeTest(test);
  30. yield return null;
  31. }
  32. protected override IEnumerator InvokeAfter(ITestAction action, Test test, UnityTestExecutionContext context)
  33. {
  34. action.AfterTest(test);
  35. yield return null;
  36. }
  37. protected override BeforeAfterTestCommandState GetState(UnityTestExecutionContext context)
  38. {
  39. // TestActionCommand does not support domain reloads and will not need a persisted state.
  40. return new BeforeAfterTestCommandState();
  41. }
  42. }
  43. }