Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

TestMustExpectAllLogsAttribute.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace UnityEngine.TestTools
  3. {
  4. /// <summary>
  5. /// The presence of this attribute makes the Test Runner expect every single log. By
  6. /// default, the runner only fails automatically on any error logs, so this adds warnings and infos as well.
  7. /// It is the same as calling `LogAssert.NoUnexpectedReceived()` at the bottom of every affected test.
  8. ///
  9. /// This attribute can be applied to test assemblies (affects every test in the assembly), fixtures (affects every test in the fixture), or on individual test methods. It is also automatically inherited from base
  10. /// fixtures.
  11. ///
  12. /// The `MustExpect` property (on by default) lets you selectively enable or disable the higher level value. For
  13. /// example when migrating an assembly to this more strict checking method, you might attach
  14. /// `[assembly:TestMustExpectAllLogs]` to the assembly itself, but whitelist individual failing fixtures and test methods
  15. /// by attaching `[TestMustExpectAllLogs(MustExpect=false)]` until they can be migrated. This also means new tests in that
  16. /// assembly would be required to have the more strict checking.
  17. /// </summary>
  18. [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
  19. public class TestMustExpectAllLogsAttribute : Attribute
  20. {
  21. /// <summary>
  22. /// Initializes and returns an instance of TestMustExpectAllLogsAttribute.
  23. /// </summary>
  24. /// <param name="mustExpect">
  25. /// A value indicating whether the test must expect all logs.
  26. /// </param>
  27. public TestMustExpectAllLogsAttribute(bool mustExpect = true)
  28. => MustExpect = mustExpect;
  29. /// <summary>
  30. /// Returns the flag of whether the test must expect all logs.
  31. /// </summary>
  32. public bool MustExpect { get; }
  33. }
  34. }