Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
using System;
using NUnit.Framework.Interfaces;
using UnityEngine.Events;
namespace UnityEngine.TestTools.TestRunner
{
internal interface ITestRunnerListener
{
void RunStarted(ITest testsToRun);
void RunFinished(ITestResult testResults);
void TestStarted(ITest test);
void TestFinished(ITestResult result);
}
[Serializable]
internal class TestFinishedEvent : UnityEvent<ITestResult> {}
[Serializable]
internal class TestStartedEvent : UnityEvent<ITest> {}
[Serializable]
internal class RunFinishedEvent : UnityEvent<ITestResult> {}
[Serializable]
internal class RunStartedEvent : UnityEvent<ITest> {}
}
using System;
using NUnit.Framework.Interfaces;
using UnityEngine.Events;
namespace UnityEngine.TestTools.TestRunner
{
internal interface ITestRunnerListener
{
void RunStarted(ITest testsToRun);
void RunFinished(ITestResult testResults);
void TestStarted(ITest test);
void TestFinished(ITestResult result);
}
[Serializable]
internal class TestFinishedEvent : UnityEvent<ITestResult> {}
[Serializable]
internal class TestStartedEvent : UnityEvent<ITest> {}
[Serializable]
internal class RunFinishedEvent : UnityEvent<ITestResult> {}
[Serializable]
internal class RunStartedEvent : UnityEvent<ITest> {}
}
fileFormatVersion: 2
guid: d1b534518943030499685344fd1d476d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d1b534518943030499685344fd1d476d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 256a0ca37fa972840bce7fca446e75e7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 256a0ca37fa972840bce7fca446e75e7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
namespace UnityEngine.TestTools
{
public interface IEditModeTestYieldInstruction
{
bool ExpectDomainReload { get; }
bool ExpectedPlaymodeState { get; }
IEnumerator Perform();
}
}
using System.Collections;
namespace UnityEngine.TestTools
{
public interface IEditModeTestYieldInstruction
{
bool ExpectDomainReload { get; }
bool ExpectedPlaymodeState { get; }
IEnumerator Perform();
}
}
fileFormatVersion: 2
guid: 898bc38486fc899428fbe5bd6adfe473
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 898bc38486fc899428fbe5bd6adfe473
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
using UnityEngine.TestRunner.NUnitExtensions;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.NUnitExtensions;
using UnityEngine.TestTools.Utils;
namespace UnityEngine.TestTools.TestRunner
{
[Serializable]
[AddComponentMenu("")]
internal class PlaymodeTestsController : MonoBehaviour
{
private IEnumerator m_TestSteps;
[SerializeField]
private List<string> m_AssembliesWithTests;
public List<string> AssembliesWithTests
{
get
{
return m_AssembliesWithTests;
}
set
{
m_AssembliesWithTests = value;
}
}
[SerializeField]
internal TestStartedEvent testStartedEvent = new TestStartedEvent();
[SerializeField]
internal TestFinishedEvent testFinishedEvent = new TestFinishedEvent();
[SerializeField]
internal RunStartedEvent runStartedEvent = new RunStartedEvent();
[SerializeField]
internal RunFinishedEvent runFinishedEvent = new RunFinishedEvent();
internal const string kPlaymodeTestControllerName = "Code-based tests runner";
[SerializeField]
public PlaymodeTestsControllerSettings settings = new PlaymodeTestsControllerSettings();
internal UnityTestAssemblyRunner m_Runner;
public IEnumerator Start()
{
//Skip 2 frame because Unity.
yield return null;
yield return null;
StartCoroutine(Run());
}
internal static bool IsControllerOnScene()
{
return GameObject.Find(kPlaymodeTestControllerName) != null;
}
internal static PlaymodeTestsController GetController()
{
return GameObject.Find(kPlaymodeTestControllerName).GetComponent<PlaymodeTestsController>();
}
public IEnumerator TestRunnerCoroutine()
{
while (m_TestSteps.MoveNext())
{
yield return m_TestSteps.Current;
}
if (m_Runner.IsTestComplete)
{
runFinishedEvent.Invoke(m_Runner.Result);
Cleanup();
yield return null;
}
}
public IEnumerator Run()
{
CoroutineTestWorkItem.monoBehaviourCoroutineRunner = this;
gameObject.hideFlags |= HideFlags.DontSave;
if (settings.sceneBased)
{
SceneManager.LoadScene(1, LoadSceneMode.Additive);
yield return null;
}
var testListUtil = new PlayerTestAssemblyProvider(new AssemblyLoadProxy(), m_AssembliesWithTests);
m_Runner = new UnityTestAssemblyRunner(new UnityTestAssemblyBuilder(), new PlaymodeWorkItemFactory());
var loadedTests = m_Runner.Load(testListUtil.GetUserAssemblies().Select(a => a.Assembly).ToArray(), TestPlatform.PlayMode, UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(TestPlatform.PlayMode));
loadedTests.ParseForNameDuplicates();
runStartedEvent.Invoke(m_Runner.LoadedTest);
var testListenerWrapper = new TestListenerWrapper(testStartedEvent, testFinishedEvent);
m_TestSteps = m_Runner.Run(testListenerWrapper, settings.BuildNUnitFilter()).GetEnumerator();
yield return TestRunnerCoroutine();
}
public void Cleanup()
{
if (m_Runner != null)
{
m_Runner.StopRun();
m_Runner = null;
}
if (Application.isEditor)
{
Destroy(gameObject);
}
}
public static void TryCleanup()
{
var controller = GetController();
if (controller != null)
{
controller.Cleanup();
}
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
using UnityEngine.TestRunner.NUnitExtensions;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools.NUnitExtensions;
using UnityEngine.TestTools.Utils;
namespace UnityEngine.TestTools.TestRunner
{
[Serializable]
[AddComponentMenu("")]
internal class PlaymodeTestsController : MonoBehaviour
{
private IEnumerator m_TestSteps;
[SerializeField]
private List<string> m_AssembliesWithTests;
public List<string> AssembliesWithTests
{
get
{
return m_AssembliesWithTests;
}
set
{
m_AssembliesWithTests = value;
}
}
[SerializeField]
internal TestStartedEvent testStartedEvent = new TestStartedEvent();
[SerializeField]
internal TestFinishedEvent testFinishedEvent = new TestFinishedEvent();
[SerializeField]
internal RunStartedEvent runStartedEvent = new RunStartedEvent();
[SerializeField]
internal RunFinishedEvent runFinishedEvent = new RunFinishedEvent();
internal const string kPlaymodeTestControllerName = "Code-based tests runner";
[SerializeField]
public PlaymodeTestsControllerSettings settings = new PlaymodeTestsControllerSettings();
internal UnityTestAssemblyRunner m_Runner;
public IEnumerator Start()
{
//Skip 2 frame because Unity.
yield return null;
yield return null;
StartCoroutine(Run());
}
internal static bool IsControllerOnScene()
{
return GameObject.Find(kPlaymodeTestControllerName) != null;
}
internal static PlaymodeTestsController GetController()
{
return GameObject.Find(kPlaymodeTestControllerName).GetComponent<PlaymodeTestsController>();
}
public IEnumerator TestRunnerCoroutine()
{
while (m_TestSteps.MoveNext())
{
yield return m_TestSteps.Current;
}
if (m_Runner.IsTestComplete)
{
runFinishedEvent.Invoke(m_Runner.Result);
Cleanup();
yield return null;
}
}
public IEnumerator Run()
{
CoroutineTestWorkItem.monoBehaviourCoroutineRunner = this;
gameObject.hideFlags |= HideFlags.DontSave;
if (settings.sceneBased)
{
SceneManager.LoadScene(1, LoadSceneMode.Additive);
yield return null;
}
var testListUtil = new PlayerTestAssemblyProvider(new AssemblyLoadProxy(), m_AssembliesWithTests);
m_Runner = new UnityTestAssemblyRunner(new UnityTestAssemblyBuilder(), new PlaymodeWorkItemFactory());
var loadedTests = m_Runner.Load(testListUtil.GetUserAssemblies().Select(a => a.Assembly).ToArray(), TestPlatform.PlayMode, UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(TestPlatform.PlayMode));
loadedTests.ParseForNameDuplicates();
runStartedEvent.Invoke(m_Runner.LoadedTest);
var testListenerWrapper = new TestListenerWrapper(testStartedEvent, testFinishedEvent);
m_TestSteps = m_Runner.Run(testListenerWrapper, settings.BuildNUnitFilter()).GetEnumerator();
yield return TestRunnerCoroutine();
}
public void Cleanup()
{
if (m_Runner != null)
{
m_Runner.StopRun();
m_Runner = null;
}
if (Application.isEditor)
{
Destroy(gameObject);
}
}
public static void TryCleanup()
{
var controller = GetController();
if (controller != null)
{
controller.Cleanup();
}
}
}
}
fileFormatVersion: 2
guid: 102e512f651ee834f951a2516c1ea3b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 102e512f651ee834f951a2516c1ea3b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Linq;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal.Filters;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEngine.TestTools.TestRunner
{
[Serializable]
internal class PlaymodeTestsControllerSettings
{
[SerializeField]
public TestRunnerFilter[] filters;
public bool sceneBased;
public string originalScene;
public string bootstrapScene;
public static PlaymodeTestsControllerSettings CreateRunnerSettings(TestRunnerFilter[] filters)
{
var settings = new PlaymodeTestsControllerSettings
{
filters = filters,
sceneBased = false,
originalScene = SceneManager.GetActiveScene().path,
bootstrapScene = null
};
return settings;
}
internal ITestFilter BuildNUnitFilter()
{
return new OrFilter(filters.Select(f => f.BuildNUnitFilter()).ToArray());
}
}
}
using System;
using System.Linq;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal.Filters;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools.TestRunner.GUI;
namespace UnityEngine.TestTools.TestRunner
{
[Serializable]
internal class PlaymodeTestsControllerSettings
{
[SerializeField]
public TestRunnerFilter[] filters;
public bool sceneBased;
public string originalScene;
public string bootstrapScene;
public static PlaymodeTestsControllerSettings CreateRunnerSettings(TestRunnerFilter[] filters)
{
var settings = new PlaymodeTestsControllerSettings
{
filters = filters,
sceneBased = false,
originalScene = SceneManager.GetActiveScene().path,
bootstrapScene = null
};
return settings;
}
internal ITestFilter BuildNUnitFilter()
{
return new OrFilter(filters.Select(f => f.BuildNUnitFilter()).ToArray());
}
}
}
fileFormatVersion: 2
guid: 2799eb4c84e72e54092a292cf626936b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2799eb4c84e72e54092a292cf626936b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 91c20d2c22b8b3a4cb6c816bd225591a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 91c20d2c22b8b3a4cb6c816bd225591a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using NUnit.Framework.Interfaces;
namespace UnityEngine.TestRunner.TestLaunchers
{
internal interface IRemoteTestResultDataFactory
{
RemoteTestResultDataWithTestData CreateFromTestResult(ITestResult result);
RemoteTestResultDataWithTestData CreateFromTest(ITest test);
}
}
using System;
using NUnit.Framework.Interfaces;
namespace UnityEngine.TestRunner.TestLaunchers
{
internal interface IRemoteTestResultDataFactory
{
RemoteTestResultDataWithTestData CreateFromTestResult(ITestResult result);
RemoteTestResultDataWithTestData CreateFromTest(ITest test);
}
}
fileFormatVersion: 2
guid: 874c0713cdc44f549b0161750b48d2c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 874c0713cdc44f549b0161750b48d2c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
namespace UnityEngine.TestRunner.TestLaunchers
{
internal static class PlayerConnectionMessageIds
{
public static Guid runStartedMessageId { get { return new Guid("6a7f53dd-4672-461d-a7b5-9467e9393fd3"); } }
public static Guid runFinishedMessageId { get { return new Guid("ffb622fc-34ad-4901-8d7b-47fb04b0bdd4"); } }
public static Guid testStartedMessageId { get { return new Guid("b54d241e-d88d-4dba-8c8f-ee415d11c030"); } }
public static Guid testFinishedMessageId { get { return new Guid("72f7b7f4-6829-4cd1-afde-78872b9d5adc"); } }
public static Guid quitPlayerMessageId { get { return new Guid("ab44bfe0-bb50-4ee6-9977-69d2ea6bb3a0"); } }
public static Guid playerAliveHeartbeat { get { return new Guid("8c0c307b-f7fd-4216-8623-35b4b3f55fb6"); } }
}
}
using System;
namespace UnityEngine.TestRunner.TestLaunchers
{
internal static class PlayerConnectionMessageIds
{
public static Guid runStartedMessageId { get { return new Guid("6a7f53dd-4672-461d-a7b5-9467e9393fd3"); } }
public static Guid runFinishedMessageId { get { return new Guid("ffb622fc-34ad-4901-8d7b-47fb04b0bdd4"); } }
public static Guid testStartedMessageId { get { return new Guid("b54d241e-d88d-4dba-8c8f-ee415d11c030"); } }
public static Guid testFinishedMessageId { get { return new Guid("72f7b7f4-6829-4cd1-afde-78872b9d5adc"); } }
public static Guid quitPlayerMessageId { get { return new Guid("ab44bfe0-bb50-4ee6-9977-69d2ea6bb3a0"); } }
public static Guid playerAliveHeartbeat { get { return new Guid("8c0c307b-f7fd-4216-8623-35b4b3f55fb6"); } }
}
}
fileFormatVersion: 2
guid: 41d60936b62cc6d4ca7fe628b22b0e40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 41d60936b62cc6d4ca7fe628b22b0e40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Linq;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using UnityEngine.TestRunner.NUnitExtensions;
namespace UnityEngine.TestRunner.TestLaunchers
{
[Serializable]
internal class RemoteTestData
{
public string id;
public string name;
public string fullName;
public int testCaseCount;
public int ChildIndex;
public bool hasChildren;
public bool isSuite;
public string[] childrenIds;
public int testCaseTimeout;
public string[] Categories;
public bool IsTestAssembly;
public RunState RunState;
public string Description;
public string SkipReason;
public string ParentId;
public string UniqueName;
public string ParentUniqueName;
public string ParentFullName;
internal RemoteTestData(ITest test)
{
id = test.Id;
name = test.Name;
fullName = test.FullName;
testCaseCount = test.TestCaseCount;
ChildIndex = -1;
if (test.Properties["childIndex"].Count > 0)
{
ChildIndex = (int)test.Properties["childIndex"][0];
}
hasChildren = test.HasChildren;
isSuite = test.IsSuite;
childrenIds = test.Tests.Select(t => t.Id).ToArray();
Categories = test.GetAllCategoriesFromTest().ToArray();
IsTestAssembly = test is TestAssembly;
RunState = (RunState)Enum.Parse(typeof(RunState), test.RunState.ToString());
Description = (string)test.Properties.Get(PropertyNames.Description);
SkipReason = test.GetSkipReason();
ParentId = test.GetParentId();
UniqueName = test.GetUniqueName();
ParentUniqueName = test.GetParentUniqueName();
ParentFullName = test.GetParentFullName();
}
}
}
using System;
using System.Linq;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using UnityEngine.TestRunner.NUnitExtensions;
namespace UnityEngine.TestRunner.TestLaunchers
{
[Serializable]
internal class RemoteTestData
{
public string id;
public string name;
public string fullName;
public int testCaseCount;
public int ChildIndex;
public bool hasChildren;
public bool isSuite;
public string[] childrenIds;
public int testCaseTimeout;
public string[] Categories;
public bool IsTestAssembly;
public RunState RunState;
public string Description;
public string SkipReason;
public string ParentId;
public string UniqueName;
public string ParentUniqueName;
public string ParentFullName;
internal RemoteTestData(ITest test)
{
id = test.Id;
name = test.Name;
fullName = test.FullName;
testCaseCount = test.TestCaseCount;
ChildIndex = -1;
if (test.Properties["childIndex"].Count > 0)
{
ChildIndex = (int)test.Properties["childIndex"][0];
}
hasChildren = test.HasChildren;
isSuite = test.IsSuite;
childrenIds = test.Tests.Select(t => t.Id).ToArray();
Categories = test.GetAllCategoriesFromTest().ToArray();
IsTestAssembly = test is TestAssembly;
RunState = (RunState)Enum.Parse(typeof(RunState), test.RunState.ToString());
Description = (string)test.Properties.Get(PropertyNames.Description);
SkipReason = test.GetSkipReason();
ParentId = test.GetParentId();
UniqueName = test.GetUniqueName();
ParentUniqueName = test.GetParentUniqueName();
ParentFullName = test.GetParentFullName();
}
}
}
fileFormatVersion: 2
guid: b135ec222fdcd11468014c90d11d6821
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b135ec222fdcd11468014c90d11d6821
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment