30 lines
1.4 KiB
C#
30 lines
1.4 KiB
C#
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEditor.TestTools.TestRunner.Api;
|
|
using UnityEngine;
|
|
[InitializeOnLoad]
|
|
public static class PlayerAcceptance
|
|
{
|
|
private static readonly TestRunnerApi Api;
|
|
static PlayerAcceptance() { Api = ScriptableObject.CreateInstance<TestRunnerApi>(); Api.RegisterCallbacks(new Results()); }
|
|
public static string Run()
|
|
{
|
|
SessionState.SetBool("Shrink.PlayerAcceptance.Active", true);
|
|
return Api.Execute(new ExecutionSettings(new Filter { testMode = TestMode.PlayMode, assemblyNames = new[] { "ShrinkSDK.AgentSupport.PlayerTests" }, targetPlatform = BuildTarget.StandaloneWindows64 }));
|
|
}
|
|
private sealed class Results : ICallbacks
|
|
{
|
|
public void RunStarted(ITestAdaptor tests) { }
|
|
public void TestStarted(ITestAdaptor test) { }
|
|
public void TestFinished(ITestResultAdaptor result) { }
|
|
public void RunFinished(ITestResultAdaptor result)
|
|
{
|
|
if (!SessionState.GetBool("Shrink.PlayerAcceptance.Active", false)) return;
|
|
SessionState.SetBool("Shrink.PlayerAcceptance.Active", false);
|
|
Directory.CreateDirectory("Artifacts/AgentSupport");
|
|
File.WriteAllText("Artifacts/AgentSupport/unity-player-results.xml", result.ToXml().OuterXml);
|
|
Debug.Log("Shrink Player acceptance: " + result.PassCount + " passed, " + result.FailCount + " failed.");
|
|
}
|
|
}
|
|
}
|