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