SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

4 years ago
  1. # ConditionalIgnore attribute
  2. This attribute is an alternative to the standard `Ignore` attribute in [NUnit](http://www.nunit.org/). It allows for ignoring tests only under a specified condition. The condition evaluates during `OnLoad`, referenced by ID.
  3. ## Example
  4. The following example shows a method to use the `ConditionalIgnore` attribute to ignore a test if the Unity Editor is running macOS:
  5. ```C#
  6. using UnityEditor;
  7. using NUnit.Framework;
  8. using UnityEngine.TestTools;
  9. [InitializeOnLoad]
  10. public class OnLoad
  11. {
  12. static OnLoad()
  13. {
  14. var editorIsOSX = false;
  15. #if UNITY_EDITOR_OSX
  16. editorIsOSX = true;
  17. #endif
  18. ConditionalIgnoreAttribute.AddConditionalIgnoreMapping("IgnoreInMacEditor", editorIsOSX);
  19. }
  20. }
  21. public class MyTestClass
  22. {
  23. [Test, ConditionalIgnore("IgnoreInMacEditor", "Ignored on Mac editor.")]
  24. public void TestNeverRunningInMacEditor()
  25. {
  26. Assert.Pass();
  27. }
  28. }
  29. ```
  30. > **Note**: You can only use `InitializeOnLoad` in **Edit Mode** tests.