UnityTestAttribute.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using NUnit.Framework;
  3. using NUnit.Framework.Internal.Commands;
  4. using NUnit.Framework.Interfaces;
  5. using NUnit.Framework.Internal;
  6. using NUnit.Framework.Internal.Builders;
  7. using UnityEngine.TestRunner.NUnitExtensions.Runner;
  8. namespace UnityEngine.TestTools
  9. {
  10. [AttributeUsage(AttributeTargets.Method)]
  11. public class UnityTestAttribute : CombiningStrategyAttribute, ISimpleTestBuilder, IImplyFixture
  12. {
  13. public UnityTestAttribute() : base(new UnityCombinatorialStrategy(), new ParameterDataSourceProvider()) {}
  14. private readonly NUnitTestCaseBuilder _builder = new NUnitTestCaseBuilder();
  15. TestMethod ISimpleTestBuilder.BuildFrom(IMethodInfo method, Test suite)
  16. {
  17. TestCaseParameters parms = new TestCaseParameters
  18. {
  19. ExpectedResult = new object(),
  20. HasExpectedResult = true
  21. };
  22. var t = _builder.BuildTestMethod(method, suite, parms);
  23. if (t.parms != null)
  24. t.parms.HasExpectedResult = false;
  25. return t;
  26. }
  27. }
  28. }