diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
| commit | c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch) | |
| tree | ee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api | |
| download | Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2 Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip | |
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api')
44 files changed, 1293 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs new file mode 100644 index 0000000..9418464 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs @@ -0,0 +1,136 @@ +using System;
+using System.Linq;
+using System.Text;
+using NUnit.Framework.Interfaces;
+using NUnit.Framework.Internal;
+using UnityEngine;
+using UnityEngine.TestRunner.TestLaunchers;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class CallbacksDelegator : ICallbacksDelegator
+ {
+ private static CallbacksDelegator s_instance;
+ public static CallbacksDelegator instance
+ {
+ get
+ {
+ if (s_instance == null)
+ {
+ s_instance = new CallbacksDelegator(CallbacksHolder.instance.GetAll, new TestAdaptorFactory());
+ }
+ return s_instance;
+ }
+ }
+
+ private readonly Func<ICallbacks[]> m_CallbacksProvider;
+ private readonly ITestAdaptorFactory m_AdaptorFactory;
+
+ public CallbacksDelegator(Func<ICallbacks[]> callbacksProvider, ITestAdaptorFactory adaptorFactory)
+ {
+ m_CallbacksProvider = callbacksProvider;
+ m_AdaptorFactory = adaptorFactory;
+ }
+
+ public void RunStarted(ITest testsToRun)
+ {
+ m_AdaptorFactory.ClearResultsCache();
+ var testRunnerTestsToRun = m_AdaptorFactory.Create(testsToRun);
+ TryInvokeAllCallbacks(callbacks => callbacks.RunStarted(testRunnerTestsToRun));
+ }
+
+ public void RunStartedRemotely(byte[] testsToRunData)
+ {
+ var testData = Deserialize<RemoteTestResultDataWithTestData>(testsToRunData);
+ var testsToRun = m_AdaptorFactory.BuildTree(testData);
+ TryInvokeAllCallbacks(callbacks => callbacks.RunStarted(testsToRun));
+ }
+
+ public void RunFinished(ITestResult testResults)
+ {
+ var testResult = m_AdaptorFactory.Create(testResults);
+ TryInvokeAllCallbacks(callbacks => callbacks.RunFinished(testResult));
+ }
+
+ public void RunFinishedRemotely(byte[] testResultsData)
+ {
+ var remoteTestResult = Deserialize<RemoteTestResultDataWithTestData>(testResultsData);
+ var testResult = m_AdaptorFactory.Create(remoteTestResult.results.First(), remoteTestResult);
+ TryInvokeAllCallbacks(callbacks => callbacks.RunFinished(testResult));
+ }
+
+ public void RunFailed(string failureMessage)
+ {
+ Debug.LogError(failureMessage);
+ TryInvokeAllCallbacks(callbacks =>
+ {
+ var errorCallback = callbacks as IErrorCallbacks;
+ if (errorCallback != null)
+ {
+ errorCallback.OnError(failureMessage);
+ }
+ });
+ }
+
+ public void TestStarted(ITest test)
+ {
+ var testRunnerTest = m_AdaptorFactory.Create(test);
+ TryInvokeAllCallbacks(callbacks => callbacks.TestStarted(testRunnerTest));
+ }
+
+ public void TestStartedRemotely(byte[] testStartedData)
+ {
+ var testData = Deserialize<RemoteTestResultDataWithTestData>(testStartedData);
+ var testsToRun = m_AdaptorFactory.BuildTree(testData);
+
+ TryInvokeAllCallbacks(callbacks => callbacks.TestStarted(testsToRun));
+ }
+
+ public void TestFinished(ITestResult result)
+ {
+ var testResult = m_AdaptorFactory.Create(result);
+ TryInvokeAllCallbacks(callbacks => callbacks.TestFinished(testResult));
+ }
+
+ public void TestFinishedRemotely(byte[] testResultsData)
+ {
+ var remoteTestResult = Deserialize<RemoteTestResultDataWithTestData>(testResultsData);
+ var testResult = m_AdaptorFactory.Create(remoteTestResult.results.First(), remoteTestResult);
+ TryInvokeAllCallbacks(callbacks => callbacks.TestFinished(testResult));
+ }
+
+ public void TestTreeRebuild(ITest test)
+ {
+ m_AdaptorFactory.ClearTestsCache();
+ var testAdaptor = m_AdaptorFactory.Create(test);
+ TryInvokeAllCallbacks(callbacks =>
+ {
+ var rebuildCallbacks = callbacks as ITestTreeRebuildCallbacks;
+ if (rebuildCallbacks != null)
+ {
+ rebuildCallbacks.TestTreeRebuild(testAdaptor);
+ }
+ });
+ }
+
+ private void TryInvokeAllCallbacks(Action<ICallbacks> callbackAction)
+ {
+ foreach (var testRunnerApiCallback in m_CallbacksProvider())
+ {
+ try
+ {
+ callbackAction(testRunnerApiCallback);
+ }
+ catch (Exception ex)
+ {
+ Debug.LogException(ex);
+ }
+ }
+ }
+
+ private static T Deserialize<T>(byte[] data)
+ {
+ return JsonUtility.FromJson<T>(Encoding.UTF8.GetString(data));
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs.meta new file mode 100644 index 0000000..5225c54 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 0de03ebd74e2b474fa23d05ab42d0cd8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs new file mode 100644 index 0000000..b3cb5b8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs @@ -0,0 +1,28 @@ +using UnityEngine;
+using UnityEngine.TestTools.TestRunner;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class CallbacksDelegatorListener : ScriptableObject, ITestRunnerListener
+ {
+ public void RunStarted(NUnit.Framework.Interfaces.ITest testsToRun)
+ {
+ CallbacksDelegator.instance.RunStarted(testsToRun);
+ }
+
+ public void RunFinished(NUnit.Framework.Interfaces.ITestResult testResults)
+ {
+ CallbacksDelegator.instance.RunFinished(testResults);
+ }
+
+ public void TestStarted(NUnit.Framework.Interfaces.ITest test)
+ {
+ CallbacksDelegator.instance.TestStarted(test);
+ }
+
+ public void TestFinished(NUnit.Framework.Interfaces.ITestResult result)
+ {
+ CallbacksDelegator.instance.TestFinished(result);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs.meta new file mode 100644 index 0000000..7bed372 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksDelegatorListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: f3e1b3cbf3fac6a459b1a602167ad311
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs new file mode 100644 index 0000000..91acb8c --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs @@ -0,0 +1,69 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class CallbacksHolder : ScriptableSingleton<CallbacksHolder>, ICallbacksHolder
+ {
+ private List<CallbackWithPriority> m_Callbacks = new List<CallbackWithPriority>();
+ public void Add(ICallbacks callback, int priority)
+ {
+ m_Callbacks.Add(new CallbackWithPriority(callback, priority));
+ }
+
+ public void Remove(ICallbacks callback)
+ {
+ m_Callbacks.RemoveAll(callbackWithPriority => callbackWithPriority.Callback == callback);
+ }
+
+ public ICallbacks[] GetAll()
+ {
+ return m_Callbacks.OrderByDescending(callback => callback.Priority).Select(callback => callback.Callback).ToArray();
+ }
+
+ public void Clear()
+ {
+ m_Callbacks.Clear();
+ }
+
+ private struct CallbackWithPriority
+ {
+ public ICallbacks Callback;
+ public int Priority;
+ public CallbackWithPriority(ICallbacks callback, int priority)
+ {
+ Callback = callback;
+ Priority = priority;
+ }
+ }
+
+ // Sometimes - such as when we want to test the test framework itself - it's necessary to launch a test run from
+ // inside a test. Because callbacks are registered globally, this can cause a lot of confusion (e.g. the in-test
+ // run will emit UTP messages, utterly confusing UTR). In such circumstances the safest thing to do is to
+ // temporarily suppress all registered callbacks for the duration of the in-test run. This method can be called
+ // to set up a using() block which will suppress the callbacks for the scope.
+ public IDisposable TemporarilySuppressCallbacks()
+ {
+ return new Suppressor(this);
+ }
+
+ private sealed class Suppressor : IDisposable
+ {
+ private readonly CallbacksHolder _instance;
+ private readonly List<CallbackWithPriority> _suppressed;
+
+ public Suppressor(CallbacksHolder instance)
+ {
+ _instance = instance;
+ _suppressed = new List<CallbackWithPriority>(instance.m_Callbacks);
+ instance.m_Callbacks.Clear();
+ }
+
+ public void Dispose()
+ {
+ _instance.m_Callbacks.AddRange(_suppressed);
+ }
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs.meta new file mode 100644 index 0000000..1896ba8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/CallbacksHolder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 4884ccc3528cb2e40a0e6f0a19a2b35b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs new file mode 100644 index 0000000..2dd115a --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs @@ -0,0 +1,57 @@ +using System;
+using System.Linq;
+using NUnit.Framework.Interfaces;
+using NUnit.Framework.Internal.Filters;
+using UnityEngine;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ [Serializable]
+ public class ExecutionSettings
+ {
+ public ExecutionSettings(params Filter[] filtersToExecute)
+ {
+ filters = filtersToExecute;
+ }
+
+ [SerializeField]
+ internal BuildTarget? targetPlatform;
+
+ // Note: Is not available after serialization
+ public ITestRunSettings overloadTestRunSettings;
+
+ [SerializeField]
+ internal Filter filter;
+ [SerializeField]
+ public Filter[] filters;
+ [SerializeField]
+ public bool runSynchronously;
+ [SerializeField]
+ public int playerHeartbeatTimeout = 60*10;
+
+ internal bool EditModeIncluded()
+ {
+ return filters.Any(f => IncludesTestMode(f.testMode, TestMode.EditMode));
+ }
+
+ internal bool PlayModeInEditorIncluded()
+ {
+ return filters.Any(f => IncludesTestMode(f.testMode, TestMode.PlayMode) && targetPlatform == null);
+ }
+
+ internal bool PlayerIncluded()
+ {
+ return filters.Any(f => IncludesTestMode(f.testMode, TestMode.PlayMode) && targetPlatform != null);
+ }
+
+ private static bool IncludesTestMode(TestMode testMode, TestMode modeToCheckFor)
+ {
+ return (testMode & modeToCheckFor) == modeToCheckFor;
+ }
+
+ internal ITestFilter BuildNUnitFilter()
+ {
+ return new OrFilter(filters.Select(f => f.BuildNUnitFilter(runSynchronously)).ToArray());
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs.meta new file mode 100644 index 0000000..7036257 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ExecutionSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: eea34a28297f9bc4c9f4c573bc8d5d1c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs new file mode 100644 index 0000000..bc10b01 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs @@ -0,0 +1,81 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework.Interfaces;
+using NUnit.Framework.Internal;
+using NUnit.Framework.Internal.Filters;
+using UnityEngine;
+using UnityEngine.TestRunner.NUnitExtensions.Filters;
+using UnityEngine.TestTools.TestRunner.GUI;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ [Serializable]
+ public class Filter
+ {
+ [SerializeField]
+ public TestMode testMode;
+ [SerializeField]
+ public string[] testNames;
+ [SerializeField]
+ public string[] groupNames;
+ [SerializeField]
+ public string[] categoryNames;
+ [SerializeField]
+ public string[] assemblyNames;
+ [SerializeField]
+ public BuildTarget? targetPlatform;
+
+ internal TestRunnerFilter ToTestRunnerFilter()
+ {
+ return new TestRunnerFilter()
+ {
+ testNames = testNames,
+ categoryNames = categoryNames,
+ groupNames = groupNames,
+ assemblyNames = assemblyNames
+ };
+ }
+
+ internal ITestFilter BuildNUnitFilter(bool synchronousOnly)
+ {
+ var filters = new List<ITestFilter>();
+
+ if (testNames != null && testNames.Length != 0)
+ {
+ var nameFilter = new OrFilter(testNames.Select(n => new FullNameFilter(n)).ToArray());
+ filters.Add(nameFilter);
+ }
+
+ if (groupNames != null && groupNames.Length != 0)
+ {
+ var exactNamesFilter = new OrFilter(groupNames.Select(n =>
+ {
+ var f = new FullNameFilter(n);
+ f.IsRegex = true;
+ return f;
+ }).ToArray());
+ filters.Add(exactNamesFilter);
+ }
+
+ if (assemblyNames != null && assemblyNames.Length != 0)
+ {
+ var assemblyFilter = new OrFilter(assemblyNames.Select(c => new AssemblyNameFilter(c)).ToArray());
+ filters.Add(assemblyFilter);
+ }
+
+ if (categoryNames != null && categoryNames.Length != 0)
+ {
+ var categoryFilter = new OrFilter(categoryNames.Select(c => new CategoryFilterExtended(c) {IsRegex = true}).ToArray());
+ filters.Add(categoryFilter);
+ }
+
+ if (synchronousOnly)
+ {
+ filters.Add(new SynchronousFilter());
+ }
+
+ return filters.Count == 0 ? TestFilter.Empty : new AndFilter(filters.ToArray());
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs.meta new file mode 100644 index 0000000..cec8610 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/Filter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 05f92e4a2414cb144a92157752dfa324
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs new file mode 100644 index 0000000..269dbbf --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs @@ -0,0 +1,10 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public interface ICallbacks
+ {
+ void RunStarted(ITestAdaptor testsToRun);
+ void RunFinished(ITestResultAdaptor result);
+ void TestStarted(ITestAdaptor test);
+ void TestFinished(ITestResultAdaptor result);
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs.meta new file mode 100644 index 0000000..ab0ac56 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacks.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 93eea84e53d0226479c9a584f19427b5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs new file mode 100644 index 0000000..5622c82 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs @@ -0,0 +1,18 @@ +using NUnit.Framework.Interfaces;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal interface ICallbacksDelegator
+ {
+ void RunStarted(ITest testsToRun);
+ void RunStartedRemotely(byte[] testsToRunData);
+ void RunFinished(ITestResult testResults);
+ void RunFinishedRemotely(byte[] testResultsData);
+ void RunFailed(string failureMessage);
+ void TestStarted(ITest test);
+ void TestStartedRemotely(byte[] testStartedData);
+ void TestFinished(ITestResult result);
+ void TestFinishedRemotely(byte[] testResultsData);
+ void TestTreeRebuild(ITest test);
+ }
+}
\ No newline at end of file diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs.meta new file mode 100644 index 0000000..fd5aae8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksDelegator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 8f8f74fe8e363da42875d9cab025d3b2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs new file mode 100644 index 0000000..5d3a652 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs @@ -0,0 +1,10 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal interface ICallbacksHolder
+ {
+ void Add(ICallbacks callback, int priority);
+ void Remove(ICallbacks callback);
+ ICallbacks[] GetAll();
+ void Clear();
+ }
+}
\ No newline at end of file diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs.meta new file mode 100644 index 0000000..dd53319 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ICallbacksHolder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: d742f2caefd9f934d9f19dad07a08e6f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs new file mode 100644 index 0000000..4599e16 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs @@ -0,0 +1,7 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public interface IErrorCallbacks : ICallbacks
+ {
+ void OnError(string message);
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs.meta new file mode 100644 index 0000000..082ebbd --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/IErrorCallbacks.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 1a06c562b0c5eb046bcb876a29f93c98
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs new file mode 100644 index 0000000..4fa05fd --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic;
+using NUnit.Framework.Interfaces;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public interface ITestAdaptor
+ {
+ string Id { get; }
+ string Name { get; }
+ string FullName { get; }
+ int TestCaseCount { get; }
+ bool HasChildren { get; }
+ bool IsSuite { get; }
+ IEnumerable<ITestAdaptor> Children { get; }
+ ITestAdaptor Parent { get; }
+ int TestCaseTimeout { get; }
+ ITypeInfo TypeInfo { get; }
+ IMethodInfo Method { get; }
+ string[] Categories { get; }
+ bool IsTestAssembly { get; }
+ RunState RunState { get; }
+ string Description { get; }
+ string SkipReason { get; }
+ string ParentId { get; }
+ string ParentFullName { get; }
+ string UniqueName { get; }
+ string ParentUniqueName { get; }
+ int ChildIndex { get; }
+ TestMode TestMode { get; }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs.meta new file mode 100644 index 0000000..a372e43 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 85dd7af03f02aea4aae13a3945e3b313
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs new file mode 100644 index 0000000..578c053 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic;
+using NUnit.Framework.Interfaces;
+using UnityEngine.TestRunner.TestLaunchers;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal interface ITestAdaptorFactory
+ {
+ ITestAdaptor Create(ITest test);
+ ITestAdaptor Create(RemoteTestData testData);
+ ITestResultAdaptor Create(ITestResult testResult);
+ ITestResultAdaptor Create(RemoteTestResultData testResult, RemoteTestResultDataWithTestData allData);
+ ITestAdaptor BuildTree(RemoteTestResultDataWithTestData data);
+ IEnumerator<ITestAdaptor> BuildTreeAsync(RemoteTestResultDataWithTestData data);
+ void ClearResultsCache();
+ void ClearTestsCache();
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs.meta new file mode 100644 index 0000000..b75d48c --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestAdaptorFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 803abab0f7e17044db56f8760186dbd1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs new file mode 100644 index 0000000..f2249f2 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs @@ -0,0 +1,86 @@ +using System;
+using System.Collections.Generic;
+using NUnit.Framework.Interfaces;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public interface ITestResultAdaptor
+ {
+ ITestAdaptor Test { get; }
+ string Name { get; }
+
+ /// <summary>Gets the full name of the test result</summary>
+ string FullName { get; }
+
+ string ResultState { get; }
+
+ TestStatus TestStatus { get; }
+
+ /// <summary>Gets the elapsed time for running the test in seconds</summary>
+ double Duration { get; }
+
+ /// <summary>Gets or sets the time the test started running.</summary>
+ DateTime StartTime { get; }
+
+ /// <summary>Gets or sets the time the test finished running.</summary>
+ DateTime EndTime { get; }
+
+ /// <summary>
+ /// Gets the message associated with a test
+ /// failure or with not running the test
+ /// </summary>
+ string Message { get; }
+
+ /// <summary>
+ /// Gets any stacktrace associated with an
+ /// error or failure. Not available in
+ /// the Compact Framework 1.0.
+ /// </summary>
+ string StackTrace { get; }
+
+ /// <summary>
+ /// Gets the number of asserts executed
+ /// when running the test and all its children.
+ /// </summary>
+ int AssertCount { get; }
+
+ /// <summary>
+ /// Gets the number of test cases that failed
+ /// when running the test and all its children.
+ /// </summary>
+ int FailCount { get; }
+
+ /// <summary>
+ /// Gets the number of test cases that passed
+ /// when running the test and all its children.
+ /// </summary>
+ int PassCount { get; }
+
+ /// <summary>
+ /// Gets the number of test cases that were skipped
+ /// when running the test and all its children.
+ /// </summary>
+ int SkipCount { get; }
+
+ /// <summary>
+ /// Gets the number of test cases that were inconclusive
+ /// when running the test and all its children.
+ /// </summary>
+ int InconclusiveCount { get; }
+
+ /// <summary>
+ /// Indicates whether this result has any child results.
+ /// Accessing HasChildren should not force creation of the
+ /// Children collection in classes implementing this interface.
+ /// </summary>
+ bool HasChildren { get; }
+
+ /// <summary>Gets the the collection of child results.</summary>
+ IEnumerable<ITestResultAdaptor> Children { get; }
+
+ /// <summary>Gets any text output written to this result.</summary>
+ string Output { get; }
+
+ TNode ToXml();
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs.meta new file mode 100644 index 0000000..991d6f6 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestResultAdaptor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 4f90cfe4bf5cfb44f84a5b11387f2a42
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs new file mode 100644 index 0000000..ea30021 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs @@ -0,0 +1,9 @@ +using System;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public interface ITestRunSettings : IDisposable
+ {
+ void Apply();
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs.meta new file mode 100644 index 0000000..0151bee --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 2ae2ce6274819484fa8747a28cebdf3a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs new file mode 100644 index 0000000..3a2388d --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs @@ -0,0 +1,12 @@ +using System;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal interface ITestRunnerApi
+ {
+ string Execute(ExecutionSettings executionSettings);
+ void RegisterCallbacks<T>(T testCallbacks, int priority = 0) where T : ICallbacks;
+ void UnregisterCallbacks<T>(T testCallbacks) where T : ICallbacks;
+ void RetrieveTestList(TestMode testMode, Action<ITestAdaptor> callback);
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs.meta new file mode 100644 index 0000000..7679b0a --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestRunnerApi.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: a7842a837a4b13e41ae16193db753418
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs new file mode 100644 index 0000000..e71d026 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs @@ -0,0 +1,7 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal interface ITestTreeRebuildCallbacks : ICallbacks
+ {
+ void TestTreeRebuild(ITestAdaptor test);
+ }
+}
\ No newline at end of file diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs.meta new file mode 100644 index 0000000..1e6ead2 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/ITestTreeRebuildCallbacks.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 4230e406313f1db43a4b548e7a3ad2e2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs new file mode 100644 index 0000000..937e39e --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs @@ -0,0 +1,11 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public enum RunState
+ {
+ NotRunnable,
+ Runnable,
+ Explicit,
+ Skipped,
+ Ignored,
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs.meta new file mode 100644 index 0000000..031239f --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/RunState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 8bb59cb2f66d156418ca1bd1e2703233
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs new file mode 100644 index 0000000..89274dc --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs @@ -0,0 +1,142 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using NUnit.Framework.Interfaces;
+using NUnit.Framework.Internal;
+using UnityEngine.TestRunner.NUnitExtensions;
+using UnityEngine.TestRunner.NUnitExtensions.Runner;
+using UnityEngine.TestRunner.TestLaunchers;
+using UnityEngine.TestTools.Utils;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class TestAdaptor : ITestAdaptor
+ {
+ internal TestAdaptor(ITest test, ITestAdaptor[] children = null)
+ {
+ Id = test.Id;
+ Name = test.Name;
+ var childIndex = -1;
+ if (test.Properties["childIndex"].Count > 0)
+ {
+ childIndex = (int)test.Properties["childIndex"][0];
+ }
+ FullName = childIndex != -1 ? GetIndexedTestCaseName(test.FullName, childIndex) : test.FullName;
+ TestCaseCount = test.TestCaseCount;
+ HasChildren = test.HasChildren;
+ IsSuite = test.IsSuite;
+ if (UnityTestExecutionContext.CurrentContext != null)
+ {
+ TestCaseTimeout = UnityTestExecutionContext.CurrentContext.TestCaseTimeout;
+ }
+ else
+ {
+ TestCaseTimeout = CoroutineRunner.k_DefaultTimeout;
+ }
+
+ TypeInfo = test.TypeInfo;
+ Method = test.Method;
+ Categories = test.GetAllCategoriesFromTest().Distinct().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();
+ ParentFullName = test.GetParentFullName();
+ UniqueName = test.GetUniqueName();
+ ParentUniqueName = test.GetParentUniqueName();
+ ChildIndex = childIndex;
+
+ if (test.Parent != null)
+ {
+ if (test.Parent.Parent == null) // Assembly level
+ {
+ TestMode = (TestMode)Enum.Parse(typeof(TestMode),test.Properties.Get("platform").ToString());
+ }
+ }
+
+ Children = children;
+ }
+
+ public void SetParent(ITestAdaptor parent)
+ {
+ Parent = parent;
+ if (parent != null)
+ {
+ TestMode = parent.TestMode;
+ }
+ }
+
+ internal TestAdaptor(RemoteTestData test)
+ {
+ Id = test.id;
+ Name = test.name;
+ FullName = test.ChildIndex != -1 ? GetIndexedTestCaseName(test.fullName, test.ChildIndex) : test.fullName;
+ TestCaseCount = test.testCaseCount;
+ HasChildren = test.hasChildren;
+ IsSuite = test.isSuite;
+ m_ChildrenIds = test.childrenIds;
+ TestCaseTimeout = test.testCaseTimeout;
+ Categories = test.Categories;
+ IsTestAssembly = test.IsTestAssembly;
+ RunState = (RunState)Enum.Parse(typeof(RunState), test.RunState.ToString());
+ Description = test.Description;
+ SkipReason = test.SkipReason;
+ ParentId = test.ParentId;
+ UniqueName = test.UniqueName;
+ ParentUniqueName = test.ParentUniqueName;
+ ParentFullName = test.ParentFullName;
+ ChildIndex = test.ChildIndex;
+ TestMode = TestMode.PlayMode;
+ }
+
+ internal void ApplyChildren(IEnumerable<TestAdaptor> allTests)
+ {
+ Children = m_ChildrenIds.Select(id => allTests.First(t => t.Id == id)).ToArray();
+ if (!string.IsNullOrEmpty(ParentId))
+ {
+ Parent = allTests.FirstOrDefault(t => t.Id == ParentId);
+ }
+ }
+
+ public string Id { get; private set; }
+ public string Name { get; private set; }
+ public string FullName { get; private set; }
+ public int TestCaseCount { get; private set; }
+ public bool HasChildren { get; private set; }
+ public bool IsSuite { get; private set; }
+ public IEnumerable<ITestAdaptor> Children { get; private set; }
+ public ITestAdaptor Parent { get; private set; }
+ public int TestCaseTimeout { get; private set; }
+ public ITypeInfo TypeInfo { get; private set; }
+ public IMethodInfo Method { get; private set; }
+ private string[] m_ChildrenIds;
+ public string[] Categories { get; private set; }
+ public bool IsTestAssembly { get; private set; }
+ public RunState RunState { get; }
+ public string Description { get; }
+ public string SkipReason { get; }
+ public string ParentId { get; }
+ public string ParentFullName { get; }
+ public string UniqueName { get; }
+ public string ParentUniqueName { get; }
+ public int ChildIndex { get; }
+ public TestMode TestMode { get; private set; }
+
+ private static string GetIndexedTestCaseName(string fullName, int index)
+ {
+ var generatedTestSuffix = " GeneratedTestCase" + index;
+ if (fullName.EndsWith(")"))
+ {
+ // Test names from generated TestCaseSource look like Test(TestCaseSourceType)
+ // This inserts a unique test case index in the name, so that it becomes Test(TestCaseSourceType GeneratedTestCase0)
+ return fullName.Substring(0, fullName.Length - 1) + generatedTestSuffix + fullName[fullName.Length - 1];
+ }
+
+ // In some cases there can be tests with duplicate names generated in other ways and they won't have () in their name
+ // We just append a suffix at the end of the name in that case
+ return fullName + generatedTestSuffix;
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs.meta new file mode 100644 index 0000000..273c463 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 6e0e62db88935c74288c97c907243bd0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs new file mode 100644 index 0000000..9c747f9 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework.Interfaces;
+using UnityEngine.TestRunner.NUnitExtensions;
+using UnityEngine.TestRunner.TestLaunchers;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class TestAdaptorFactory : ITestAdaptorFactory
+ {
+ private Dictionary<string, TestAdaptor> m_TestAdaptorCache = new Dictionary<string, TestAdaptor>();
+ private Dictionary<string, TestResultAdaptor> m_TestResultAdaptorCache = new Dictionary<string, TestResultAdaptor>();
+ public ITestAdaptor Create(ITest test)
+ {
+ var uniqueName = test.GetUniqueName();
+ if (m_TestAdaptorCache.ContainsKey(uniqueName))
+ {
+ return m_TestAdaptorCache[uniqueName];
+ }
+
+ var adaptor = new TestAdaptor(test, test.Tests.Select(Create).ToArray());
+ foreach (var child in adaptor.Children)
+ {
+ (child as TestAdaptor).SetParent(adaptor);
+ }
+ m_TestAdaptorCache[uniqueName] = adaptor;
+ return adaptor;
+ }
+
+ public ITestAdaptor Create(RemoteTestData testData)
+ {
+ return new TestAdaptor(testData);
+ }
+
+ public ITestResultAdaptor Create(ITestResult testResult)
+ {
+ var uniqueName = testResult.Test.GetUniqueName();
+ if (m_TestResultAdaptorCache.ContainsKey(uniqueName))
+ {
+ return m_TestResultAdaptorCache[uniqueName];
+ }
+ var adaptor = new TestResultAdaptor(testResult, Create(testResult.Test), testResult.Children.Select(Create).ToArray());
+ m_TestResultAdaptorCache[uniqueName] = adaptor;
+ return adaptor;
+ }
+
+ public ITestResultAdaptor Create(RemoteTestResultData testResult, RemoteTestResultDataWithTestData allData)
+ {
+ return new TestResultAdaptor(testResult, allData);
+ }
+
+ public ITestAdaptor BuildTree(RemoteTestResultDataWithTestData data)
+ {
+ var tests = data.tests.Select(remoteTestData => new TestAdaptor(remoteTestData)).ToList();
+
+ foreach (var test in tests)
+ {
+ test.ApplyChildren(tests);
+ }
+
+ return tests.First();
+ }
+
+ public IEnumerator<ITestAdaptor> BuildTreeAsync(RemoteTestResultDataWithTestData data)
+ {
+ var tests = data.tests.Select(remoteTestData => new TestAdaptor(remoteTestData)).ToList();
+
+ for (var index = 0; index < tests.Count; index++)
+ {
+ var test = tests[index];
+ test.ApplyChildren(tests);
+ if (index % 100 == 0)
+ {
+ yield return null;
+ }
+ }
+
+ yield return tests.First();
+ }
+
+ public void ClearResultsCache()
+ {
+ m_TestResultAdaptorCache.Clear();
+ }
+
+ public void ClearTestsCache()
+ {
+ m_TestAdaptorCache.Clear();
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs.meta new file mode 100644 index 0000000..65e4da7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestAdaptorFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: d0663d520c26b7c48a4135599e66acf8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs new file mode 100644 index 0000000..d22b732 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs @@ -0,0 +1,11 @@ +using System;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ [Flags]
+ public enum TestMode
+ {
+ EditMode = 1 << 0,
+ PlayMode = 1 << 1
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs.meta new file mode 100644 index 0000000..5812ce3 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: cad095eccea17b741bc4cd264e7441cd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs new file mode 100644 index 0000000..61501ac --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs @@ -0,0 +1,87 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework.Interfaces;
+using UnityEngine.TestRunner.TestLaunchers;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ internal class TestResultAdaptor : ITestResultAdaptor
+ {
+ private TNode m_Node;
+
+ internal TestResultAdaptor(ITestResult result, ITestAdaptor test, ITestResultAdaptor[] children = null)
+ {
+ Test = test;
+ Name = result.Name;
+ FullName = result.FullName;
+ ResultState = result.ResultState.ToString();
+ TestStatus = ParseTestStatus(result.ResultState.Status);
+ Duration = result.Duration;
+ StartTime = result.StartTime;
+ EndTime = result.EndTime;
+ Message = result.Message;
+ StackTrace = result.StackTrace;
+ AssertCount = result.AssertCount;
+ FailCount = result.FailCount;
+ PassCount = result.PassCount;
+ SkipCount = result.SkipCount;
+ InconclusiveCount = result.InconclusiveCount;
+ HasChildren = result.HasChildren;
+ Output = result.Output;
+ Children = children;
+ m_Node = result.ToXml(true);
+ }
+
+ internal TestResultAdaptor(RemoteTestResultData result, RemoteTestResultDataWithTestData allData)
+ {
+ Test = new TestAdaptor(allData.tests.First(t => t.id == result.testId));
+ Name = result.name;
+ FullName = result.fullName;
+ ResultState = result.resultState;
+ TestStatus = ParseTestStatus(result.testStatus);
+ Duration = result.duration;
+ StartTime = result.startTime;
+ EndTime = result.endTime;
+ Message = result.message;
+ StackTrace = result.stackTrace;
+ AssertCount = result.assertCount;
+ FailCount = result.failCount;
+ PassCount = result.passCount;
+ SkipCount = result.skipCount;
+ InconclusiveCount = result.inconclusiveCount;
+ HasChildren = result.hasChildren;
+ Output = result.output;
+ Children = result.childrenIds.Select(childId => new TestResultAdaptor(allData.results.First(r => r.testId == childId), allData)).ToArray();
+ m_Node = TNode.FromXml(result.xml);
+ }
+
+ public ITestAdaptor Test { get; private set; }
+ public string Name { get; private set; }
+ public string FullName { get; private set; }
+ public string ResultState { get; private set; }
+ public TestStatus TestStatus { get; private set; }
+ public double Duration { get; private set; }
+ public DateTime StartTime { get; private set; }
+ public DateTime EndTime { get; private set; }
+ public string Message { get; private set; }
+ public string StackTrace { get; private set; }
+ public int AssertCount { get; private set; }
+ public int FailCount { get; private set; }
+ public int PassCount { get; private set; }
+ public int SkipCount { get; private set; }
+ public int InconclusiveCount { get; private set; }
+ public bool HasChildren { get; private set; }
+ public IEnumerable<ITestResultAdaptor> Children { get; private set; }
+ public string Output { get; private set; }
+ public TNode ToXml()
+ {
+ return m_Node;
+ }
+
+ private static TestStatus ParseTestStatus(NUnit.Framework.Interfaces.TestStatus testStatus)
+ {
+ return (TestStatus)Enum.Parse(typeof(TestStatus), testStatus.ToString());
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs.meta new file mode 100644 index 0000000..aafad45 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestResultAdaptor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: d061ada5d3169454daf54243390b5fdb
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs new file mode 100644 index 0000000..6b14d38 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs @@ -0,0 +1,120 @@ +using System;
+using System.Linq;
+using System.Threading;
+using UnityEditor.TestTools.TestRunner.CommandLineTest;
+using UnityEditor.TestTools.TestRunner.TestRun;
+using UnityEngine;
+using UnityEngine.TestRunner.TestLaunchers;
+using UnityEngine.TestTools;
+using UnityEngine.TestTools.NUnitExtensions;
+
+namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public class TestRunnerApi : ScriptableObject, ITestRunnerApi
+ {
+ internal ICallbacksHolder callbacksHolder;
+
+ private ICallbacksHolder m_CallbacksHolder
+ {
+ get
+ {
+ if (callbacksHolder == null)
+ {
+ return CallbacksHolder.instance;
+ }
+
+ return callbacksHolder;
+ }
+ }
+
+ internal Func<ExecutionSettings,string> ScheduleJob = (executionSettings) =>
+ {
+ var runner = new TestJobRunner();
+ return runner.RunJob(new TestJobData(executionSettings));
+ };
+
+ public string Execute(ExecutionSettings executionSettings)
+ {
+ if (executionSettings == null)
+ {
+ throw new ArgumentNullException(nameof(executionSettings));
+ }
+
+ if ((executionSettings.filters == null || executionSettings.filters.Length == 0) && executionSettings.filter != null)
+ {
+ // Map filter (singular) to filters (plural), for backwards compatibility.
+ executionSettings.filters = new [] {executionSettings.filter};
+ }
+
+ if (executionSettings.targetPlatform == null && executionSettings.filters != null &&
+ executionSettings.filters.Length > 0)
+ {
+ executionSettings.targetPlatform = executionSettings.filters[0].targetPlatform;
+ }
+
+ return ScheduleJob(executionSettings);
+ }
+
+ public void RegisterCallbacks<T>(T testCallbacks, int priority = 0) where T : ICallbacks
+ {
+ if (testCallbacks == null)
+ {
+ throw new ArgumentNullException(nameof(testCallbacks));
+ }
+
+ m_CallbacksHolder.Add(testCallbacks, priority);
+ }
+
+ public void UnregisterCallbacks<T>(T testCallbacks) where T : ICallbacks
+ {
+ if (testCallbacks == null)
+ {
+ throw new ArgumentNullException(nameof(testCallbacks));
+ }
+
+ m_CallbacksHolder.Remove(testCallbacks);
+ }
+
+ internal void RetrieveTestList(ExecutionSettings executionSettings, Action<ITestAdaptor> callback)
+ {
+ if (executionSettings == null)
+ {
+ throw new ArgumentNullException(nameof(executionSettings));
+ }
+
+ var firstFilter = executionSettings.filters?.FirstOrDefault() ?? executionSettings.filter;
+ RetrieveTestList(firstFilter.testMode, callback);
+ }
+
+ public void RetrieveTestList(TestMode testMode, Action<ITestAdaptor> callback)
+ {
+ if (callback == null)
+ {
+ throw new ArgumentNullException(nameof(callback));
+ }
+
+ var platform = ParseTestMode(testMode);
+ var testAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());
+ var testAdaptorFactory = new TestAdaptorFactory();
+ var testListCache = new TestListCache(testAdaptorFactory, new RemoteTestResultDataFactory(), TestListCacheData.instance);
+ var testListProvider = new TestListProvider(testAssemblyProvider, new UnityTestAssemblyBuilder());
+ var cachedTestListProvider = new CachingTestListProvider(testListProvider, testListCache, testAdaptorFactory);
+
+ var job = new TestListJob(cachedTestListProvider, platform, (testRoot) =>
+ {
+ callback(testRoot);
+ });
+ job.Start();
+ }
+
+ internal static bool IsRunActive()
+ {
+ return RunData.instance.isRunning;
+ }
+
+ private static TestPlatform ParseTestMode(TestMode testMode)
+ {
+ return (((testMode & TestMode.EditMode) == TestMode.EditMode) ? TestPlatform.EditMode : 0) | (((testMode & TestMode.PlayMode) == TestMode.PlayMode) ? TestPlatform.PlayMode : 0);
+ }
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs.meta new file mode 100644 index 0000000..5bac273 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestRunnerApi.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 68993ba529ae04440916cb7c23bf3279
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs new file mode 100644 index 0000000..53eb81b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs @@ -0,0 +1,10 @@ +namespace UnityEditor.TestTools.TestRunner.Api
+{
+ public enum TestStatus
+ {
+ Inconclusive,
+ Skipped,
+ Passed,
+ Failed
+ }
+}
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs.meta new file mode 100644 index 0000000..6828582 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/Api/TestStatus.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2
+guid: 9ec94545c5b00344c9bd8e691f15d799
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
|
