Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor.Testing
|
||||
{
|
||||
[Serializable]
|
||||
internal class TestAdaptorContainer
|
||||
{
|
||||
public TestAdaptor[] TestAdaptors;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class TestAdaptor
|
||||
{
|
||||
public string Id;
|
||||
public string Name;
|
||||
public string FullName;
|
||||
|
||||
public string Type;
|
||||
public string Method;
|
||||
public string Assembly;
|
||||
|
||||
public int Parent;
|
||||
|
||||
public TestAdaptor(ITestAdaptor testAdaptor, int parent)
|
||||
{
|
||||
Id = testAdaptor.Id;
|
||||
Name = testAdaptor.Name;
|
||||
FullName = testAdaptor.FullName;
|
||||
|
||||
Type = testAdaptor.TypeInfo?.FullName;
|
||||
Method = testAdaptor?.Method?.Name;
|
||||
Assembly = testAdaptor.TypeInfo?.Assembly?.Location;
|
||||
|
||||
Parent = parent;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b73b3de0d473d4a1c887ab31f69b1a8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor.Testing
|
||||
{
|
||||
[Serializable]
|
||||
internal class TestResultAdaptorContainer
|
||||
{
|
||||
public TestResultAdaptor[] TestResultAdaptors;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class TestResultAdaptor
|
||||
{
|
||||
public string Name;
|
||||
public string FullName;
|
||||
|
||||
public int PassCount;
|
||||
public int FailCount;
|
||||
public int InconclusiveCount;
|
||||
public int SkipCount;
|
||||
|
||||
public string ResultState;
|
||||
public string StackTrace;
|
||||
|
||||
public TestStatusAdaptor TestStatus;
|
||||
|
||||
public int Parent;
|
||||
|
||||
public TestResultAdaptor(ITestResultAdaptor testResultAdaptor, int parent)
|
||||
{
|
||||
Name = testResultAdaptor.Name;
|
||||
FullName = testResultAdaptor.FullName;
|
||||
|
||||
PassCount = testResultAdaptor.PassCount;
|
||||
FailCount = testResultAdaptor.FailCount;
|
||||
InconclusiveCount = testResultAdaptor.InconclusiveCount;
|
||||
SkipCount = testResultAdaptor.SkipCount;
|
||||
|
||||
switch (testResultAdaptor.TestStatus)
|
||||
{
|
||||
case UnityEditor.TestTools.TestRunner.Api.TestStatus.Passed:
|
||||
TestStatus = TestStatusAdaptor.Passed;
|
||||
break;
|
||||
case UnityEditor.TestTools.TestRunner.Api.TestStatus.Skipped:
|
||||
TestStatus = TestStatusAdaptor.Skipped;
|
||||
break;
|
||||
case UnityEditor.TestTools.TestRunner.Api.TestStatus.Inconclusive:
|
||||
TestStatus = TestStatusAdaptor.Inconclusive;
|
||||
break;
|
||||
case UnityEditor.TestTools.TestRunner.Api.TestStatus.Failed:
|
||||
TestStatus = TestStatusAdaptor.Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
Parent = parent;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f47f2d030bc1d415a8d15a51dbcc39a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor.Testing
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
internal class TestRunnerApiListener
|
||||
{
|
||||
private static TestRunnerApi _testRunnerApi;
|
||||
private static TestRunnerCallbacks _testRunnerCallbacks;
|
||||
|
||||
static TestRunnerApiListener()
|
||||
{
|
||||
_testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
|
||||
_testRunnerCallbacks = new TestRunnerCallbacks();
|
||||
|
||||
_testRunnerApi.RegisterCallbacks(_testRunnerCallbacks);
|
||||
}
|
||||
|
||||
public static void RetrieveTestList(string mode)
|
||||
{
|
||||
RetrieveTestList((TestMode) Enum.Parse(typeof(TestMode), mode));
|
||||
}
|
||||
|
||||
private static void RetrieveTestList(TestMode mode)
|
||||
{
|
||||
_testRunnerApi.RetrieveTestList(mode, (ta) => _testRunnerCallbacks.TestListRetrieved(mode, ta));
|
||||
}
|
||||
|
||||
public static void ExecuteTests(string command)
|
||||
{
|
||||
// ExecuteTests format:
|
||||
// TestMode:FullName
|
||||
|
||||
var index = command.IndexOf(':');
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
var testMode = (TestMode)Enum.Parse(typeof(TestMode), command.Substring(0, index));
|
||||
var filter = command.Substring(index + 1);
|
||||
|
||||
ExecuteTests(new Filter() { testMode = testMode, testNames = new string[] { filter } });
|
||||
}
|
||||
|
||||
private static void ExecuteTests(Filter filter)
|
||||
{
|
||||
_testRunnerApi.Execute(new ExecutionSettings(filter));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b59b40c84c6a5348a188c16b17c7b40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor.Testing
|
||||
{
|
||||
internal class TestRunnerCallbacks : ICallbacks
|
||||
{
|
||||
private string Serialize<TContainer, TSource, TAdaptor>(
|
||||
TSource source,
|
||||
Func<TSource, int, TAdaptor> createAdaptor,
|
||||
Func<TSource, IEnumerable<TSource>> children,
|
||||
Func<TAdaptor[], TContainer> container)
|
||||
{
|
||||
var adaptors = new List<TAdaptor>();
|
||||
|
||||
void AddAdaptor(TSource item, int parentIndex)
|
||||
{
|
||||
var index = adaptors.Count;
|
||||
adaptors.Add(createAdaptor(item, parentIndex));
|
||||
foreach (var child in children(item))
|
||||
AddAdaptor(child, index);
|
||||
}
|
||||
|
||||
AddAdaptor(source, -1);
|
||||
|
||||
return JsonUtility.ToJson(container(adaptors.ToArray()));
|
||||
}
|
||||
|
||||
private string Serialize(ITestAdaptor testAdaptor)
|
||||
{
|
||||
return Serialize(
|
||||
testAdaptor,
|
||||
(a, parentIndex) => new TestAdaptor(a, parentIndex),
|
||||
(a) => a.Children,
|
||||
(r) => new TestAdaptorContainer { TestAdaptors = r });
|
||||
}
|
||||
|
||||
private string Serialize(ITestResultAdaptor testResultAdaptor)
|
||||
{
|
||||
return Serialize(
|
||||
testResultAdaptor,
|
||||
(a, parentIndex) => new TestResultAdaptor(a, parentIndex),
|
||||
(a) => a.Children,
|
||||
(r) => new TestResultAdaptorContainer { TestResultAdaptors = r });
|
||||
}
|
||||
|
||||
public void RunFinished(ITestResultAdaptor testResultAdaptor)
|
||||
{
|
||||
VisualStudioIntegration.BroadcastMessage(Messaging.MessageType.RunFinished, Serialize(testResultAdaptor));
|
||||
}
|
||||
|
||||
public void RunStarted(ITestAdaptor testAdaptor)
|
||||
{
|
||||
VisualStudioIntegration.BroadcastMessage(Messaging.MessageType.RunStarted, Serialize(testAdaptor));
|
||||
}
|
||||
|
||||
public void TestFinished(ITestResultAdaptor testResultAdaptor)
|
||||
{
|
||||
VisualStudioIntegration.BroadcastMessage(Messaging.MessageType.TestFinished, Serialize(testResultAdaptor));
|
||||
}
|
||||
|
||||
public void TestStarted(ITestAdaptor testAdaptor)
|
||||
{
|
||||
VisualStudioIntegration.BroadcastMessage(Messaging.MessageType.TestStarted, Serialize(testAdaptor));
|
||||
}
|
||||
|
||||
private static string TestModeName(TestMode testMode)
|
||||
{
|
||||
switch (testMode)
|
||||
{
|
||||
case TestMode.EditMode: return "EditMode";
|
||||
case TestMode.PlayMode: return "PlayMode";
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
|
||||
internal void TestListRetrieved(TestMode testMode, ITestAdaptor testAdaptor)
|
||||
{
|
||||
// TestListRetrieved format:
|
||||
// TestMode:Json
|
||||
|
||||
var value = TestModeName(testMode) + ":" + Serialize(testAdaptor);
|
||||
VisualStudioIntegration.BroadcastMessage(Messaging.MessageType.TestListRetrieved, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fae6007c1ac2cc744b2891fd4d279c96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace Microsoft.Unity.VisualStudio.Editor.Testing
|
||||
{
|
||||
[Serializable]
|
||||
internal enum TestStatusAdaptor
|
||||
{
|
||||
Passed,
|
||||
Skipped,
|
||||
Inconclusive,
|
||||
Failed,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0719f1a8b2a284e1182b352e6c8c3c60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue