No Description
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.

SyncTestRunCallback.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if TEST_FRAMEWORK
  2. using NUnit.Framework.Interfaces;
  3. using Packages.Rider.Editor.UnitTesting;
  4. using UnityEngine.TestRunner;
  5. [assembly: TestRunCallback(typeof(SyncTestRunCallback))]
  6. namespace Packages.Rider.Editor.UnitTesting
  7. {
  8. internal class SyncTestRunCallback : ITestRunCallback
  9. {
  10. public void RunStarted(ITest testsToRun)
  11. {
  12. }
  13. public void RunFinished(ITestResult testResults)
  14. {
  15. SyncTestRunEventsHandler.instance.OnRunFinished();
  16. }
  17. public void TestStarted(ITest test)
  18. {
  19. if (!test.IsSuite)
  20. SyncTestRunEventsHandler.instance.OnTestStarted(GenerateId(test));
  21. }
  22. public void TestFinished(ITestResult result)
  23. {
  24. if (!result.Test.IsSuite)
  25. SyncTestRunEventsHandler.instance.OnTestFinished();
  26. }
  27. // https://jetbrains.team/p/net/code/dotnet-libs/files/f04cde7d1dd70ee13bf5532e30f929b9b5ed08a4/ReSharperTestRunner/src/Adapters/TestRunner.Adapters.NUnit3/RemoteTaskDepot.cs?tab=source&line=129
  28. private static string GenerateId(ITest node)
  29. {
  30. // ES: Parameterized tests defined in a parametrized test fixture, though
  31. // constructed for a particular test fixture with the given parameter, have identical fullname that does
  32. // not include parameters of parent testfixture (name of the without parameters is used instead).
  33. // This leads to 'Test with {id} id is already running' message.
  34. var typeName = node.GetType().Name;
  35. if (typeName == "ParameterizedMethod" ||
  36. typeName == "GenericMethod")
  37. return $"{node.Parent.FullName}.{node.Name}";
  38. return node.FullName;
  39. }
  40. }
  41. }
  42. #endif