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.

UnityTestProtocolStarter.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEditor.TestTools.TestRunner.Api;
  5. using UnityEngine;
  6. namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
  7. {
  8. [InitializeOnLoad]
  9. internal static class UnityTestProtocolStarter
  10. {
  11. static UnityTestProtocolStarter()
  12. {
  13. var commandLineArgs = Environment.GetCommandLineArgs();
  14. if (commandLineArgs.Contains("-automated") && commandLineArgs.Contains("-runTests")) // wanna have it only for utr run
  15. {
  16. var api = ScriptableObject.CreateInstance<TestRunnerApi>();
  17. var listener = new UnityTestProtocolListener(GetRepositoryPath(commandLineArgs));
  18. api.RegisterCallbacks(listener);
  19. }
  20. }
  21. private static string GetRepositoryPath(IReadOnlyList<string> commandLineArgs)
  22. {
  23. for (var i = 0; i < commandLineArgs.Count; i++)
  24. {
  25. if (commandLineArgs[i].Equals("-projectRepositoryPath"))
  26. {
  27. return commandLineArgs[i + 1];
  28. }
  29. }
  30. return string.Empty;
  31. }
  32. }
  33. }