test
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3610673068254436ac90019f46e09f01
|
||||
timeCreated: 1686043510
|
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This class is used for serialization purposes
|
||||
// which requires public access to fields and a default empty constructor
|
||||
[Serializable]
|
||||
internal class BuildSettings
|
||||
{
|
||||
public BuildSettings(string platform, string buildTarget, bool developmentPlayer, string androidBuildSystem = "")
|
||||
{
|
||||
Platform = platform;
|
||||
BuildTarget = buildTarget;
|
||||
DevelopmentPlayer = developmentPlayer;
|
||||
AndroidBuildSystem = androidBuildSystem;
|
||||
}
|
||||
|
||||
public string Platform;
|
||||
public string BuildTarget;
|
||||
public bool DevelopmentPlayer;
|
||||
public string AndroidBuildSystem;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f699428dfee64165b017dced94d8ca70
|
||||
timeCreated: 1686043529
|
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This class is used for serialization purposes
|
||||
// which requires public access to fields and a default empty constructor
|
||||
[Serializable]
|
||||
internal class PlayerSettings
|
||||
{
|
||||
public string ScriptingBackend;
|
||||
public bool MtRendering;
|
||||
public bool GraphicsJobs;
|
||||
public bool GpuSkinning;
|
||||
public string GraphicsApi;
|
||||
public string Batchmode;
|
||||
public string StereoRenderingPath;
|
||||
public string RenderThreadingMode;
|
||||
public string AndroidMinimumSdkVersion;
|
||||
public string AndroidTargetSdkVersion;
|
||||
public string ScriptingRuntimeVersion;
|
||||
public string AndroidTargetArchitecture;
|
||||
public bool StripEngineCode;
|
||||
|
||||
public PlayerSettings(
|
||||
string scriptingBackend,
|
||||
bool gpuSkinning,
|
||||
string graphicsApi,
|
||||
string batchmode,
|
||||
string stereoRenderingPath,
|
||||
string renderThreadingMode,
|
||||
string androidTargetSdkVersion,
|
||||
string androidMinimumSdkVersion = "",
|
||||
bool graphicsJobs = false,
|
||||
bool mtRendering = false
|
||||
)
|
||||
{
|
||||
ScriptingBackend = scriptingBackend;
|
||||
GpuSkinning = gpuSkinning;
|
||||
GraphicsApi = graphicsApi;
|
||||
Batchmode = batchmode;
|
||||
StereoRenderingPath = stereoRenderingPath;
|
||||
RenderThreadingMode = renderThreadingMode;
|
||||
AndroidTargetSdkVersion = androidTargetSdkVersion;
|
||||
AndroidMinimumSdkVersion = androidMinimumSdkVersion;
|
||||
GraphicsJobs = graphicsJobs;
|
||||
MtRendering = mtRendering;
|
||||
}
|
||||
|
||||
public PlayerSettings() { }
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d52ad1cdc75642419ac24e88b43a3821
|
||||
timeCreated: 1686044146
|
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This class is used for serialization purposes
|
||||
// which requires public access to fields and a default empty constructor
|
||||
[Serializable]
|
||||
internal class PlayerSystemInfo
|
||||
{
|
||||
public PlayerSystemInfo() { }
|
||||
|
||||
public PlayerSystemInfo(string operatingSystem, string deviceModel, string deviceName, string processorType, int processorCount, string graphicsDeviceName, int systemMemorySize, string xrModel = "", string xrDevice = "")
|
||||
{
|
||||
OperatingSystem = operatingSystem;
|
||||
DeviceModel = deviceModel;
|
||||
DeviceName = deviceName;
|
||||
ProcessorType = processorType;
|
||||
ProcessorCount = processorCount;
|
||||
GraphicsDeviceName = graphicsDeviceName;
|
||||
SystemMemorySize = systemMemorySize;
|
||||
XrModel = xrModel;
|
||||
XrDevice = xrDevice;
|
||||
}
|
||||
|
||||
public string OperatingSystem;
|
||||
public string DeviceModel;
|
||||
public string DeviceName;
|
||||
public string ProcessorType;
|
||||
public int ProcessorCount;
|
||||
public string GraphicsDeviceName;
|
||||
public int SystemMemorySize;
|
||||
public string XrModel;
|
||||
public string XrDevice;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ee0c4baf94a41009b0f9292988a2000
|
||||
timeCreated: 1686044561
|
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This class is used for serialization purposes
|
||||
// which requires public access to fields and a default empty constructor
|
||||
[Serializable]
|
||||
internal class QualitySettings
|
||||
{
|
||||
public QualitySettings(int vsync, int antiAliasing, string colorSpace, string anisotropicFiltering, string blendWeights)
|
||||
{
|
||||
Vsync = vsync;
|
||||
AntiAliasing = antiAliasing;
|
||||
ColorSpace = colorSpace;
|
||||
AnisotropicFiltering = anisotropicFiltering;
|
||||
BlendWeights = blendWeights;
|
||||
}
|
||||
|
||||
public QualitySettings(){}
|
||||
|
||||
public int Vsync;
|
||||
public int AntiAliasing;
|
||||
public string ColorSpace;
|
||||
public string AnisotropicFiltering;
|
||||
public string BlendWeights;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efce3ac61ba34d3590656de761a677e3
|
||||
timeCreated: 1686048374
|
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This class is used for serialization purposes
|
||||
// which requires public access to fields and a default empty constructor
|
||||
[Serializable]
|
||||
internal class ScreenSettings
|
||||
{
|
||||
public ScreenSettings(int screenWidth, int screenHeight, int screenRefreshRate, bool fullscreen)
|
||||
{
|
||||
ScreenWidth = screenWidth;
|
||||
ScreenHeight = screenHeight;
|
||||
ScreenRefreshRate = screenRefreshRate;
|
||||
Fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
public ScreenSettings() { }
|
||||
public int ScreenWidth;
|
||||
public int ScreenHeight;
|
||||
public int ScreenRefreshRate;
|
||||
public bool Fullscreen;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58a43a62ecbe444d963930822e17d4cd
|
||||
timeCreated: 1686044804
|
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal interface ITestRunnerApiMapper
|
||||
{
|
||||
string GetRunStateFromResultNunitXml(ITestResultAdaptor result);
|
||||
TestState GetTestStateFromResult(ITestResultAdaptor result);
|
||||
List<string> FlattenTestNames(ITestAdaptor testsToRun);
|
||||
TestPlanMessage MapTestToTestPlanMessage(ITestAdaptor testsToRun);
|
||||
TestStartedMessage MapTestToTestStartedMessage(ITestAdaptor test);
|
||||
TestFinishedMessage TestResultToTestFinishedMessage(ITestResultAdaptor result);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6de79ae237e51554da96fd28f68b66a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal interface IUtpLogger
|
||||
{
|
||||
void Log(Message msg);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9014630255533ed42915965b4065cde8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal interface IUtpMessageReporter
|
||||
{
|
||||
void ReportTestFinished(ITestResultAdaptor result);
|
||||
void ReportTestRunStarted(ITestAdaptor testsToRun);
|
||||
void ReportTestStarted(ITestAdaptor test);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 952b3dc7b47846947b37c8d3ae46579a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea154c33fd8466f973f004e5c962df7
|
||||
timeCreated: 1685970469
|
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
internal class BuildSettingsMessage : Message
|
||||
{
|
||||
public BuildSettingsMessage()
|
||||
{
|
||||
type = "BuildSettings";
|
||||
}
|
||||
|
||||
public BuildSettings BuildSettings;
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b3dcba2081245eb916aee8fd3459fc8
|
||||
timeCreated: 1685970410
|
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class EditorVersionMessage : Message
|
||||
{
|
||||
public EditorVersionMessage()
|
||||
{
|
||||
type = "EditorVersion";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02ef7627f46742ae83071af8bf22f1af
|
||||
timeCreated: 1685970427
|
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
internal abstract class Message
|
||||
{
|
||||
public string type;
|
||||
// Milliseconds since unix epoch
|
||||
public ulong time;
|
||||
public int version;
|
||||
public string phase;
|
||||
public int processId;
|
||||
|
||||
protected Message()
|
||||
{
|
||||
version = 2;
|
||||
phase = "Immediate";
|
||||
processId = Process.GetCurrentProcess().Id;
|
||||
AddTimeStamp();
|
||||
}
|
||||
|
||||
public void AddTimeStamp()
|
||||
{
|
||||
time = Convert.ToUInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 321dc2c0720f8dd4f9396ecdc12b8746
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
internal class PlayerSettingsMessage : Message
|
||||
{
|
||||
public PlayerSettings PlayerSettings;
|
||||
public PlayerSettingsMessage()
|
||||
{
|
||||
type = "PlayerSettings";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa5e75ed0aae4030a1720d08f7a5322e
|
||||
timeCreated: 1685970448
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
internal class PlayerSystemInfoMessage : Message
|
||||
{
|
||||
public PlayerSystemInfo PlayerSystemInfo;
|
||||
public PlayerSystemInfoMessage()
|
||||
{
|
||||
type = "PlayerSystemInfo";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f33b8e923ff41deaa73bc2c1f90d9a1
|
||||
timeCreated: 1685970484
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
internal class QualitySettingsMessage : Message
|
||||
{
|
||||
public QualitySettings QualitySettings;
|
||||
public QualitySettingsMessage()
|
||||
{
|
||||
type = "QualitySettings";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf74526594248e88be90b91eb2dbe1c
|
||||
timeCreated: 1685970506
|
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class ScreenSettingsMessage : Message
|
||||
{
|
||||
public ScreenSettings ScreenSettings;
|
||||
|
||||
public ScreenSettingsMessage()
|
||||
{
|
||||
type = "ScreenSettings";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3936a208997f4266b0b2d48aaca1e904
|
||||
timeCreated: 1685970523
|
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class TestFinishedMessage : Message
|
||||
{
|
||||
public string name;
|
||||
public TestState state;
|
||||
public string message;
|
||||
public ulong duration; // milliseconds
|
||||
public ulong durationMicroseconds;
|
||||
public string stackTrace;
|
||||
public string fileName;
|
||||
public int lineNumber;
|
||||
public int iteration;
|
||||
|
||||
public TestFinishedMessage()
|
||||
{
|
||||
type = "TestStatus";
|
||||
phase = "End";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 423fe2ef878fa1140a7e1f7f9e365815
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class TestPlanMessage : Message
|
||||
{
|
||||
public List<string> tests;
|
||||
|
||||
public TestPlanMessage()
|
||||
{
|
||||
type = "TestPlan";
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28f79a0d7e64c2345bc46f8c4cf788f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class TestStartedMessage : Message
|
||||
{
|
||||
public string name;
|
||||
public TestState state;
|
||||
|
||||
public TestStartedMessage()
|
||||
{
|
||||
type = "TestStatus";
|
||||
phase = "Begin";
|
||||
state = TestState.Inconclusive;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd3e81baa10021f4d877fa36382bab16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Obsolete("No longer in use")]
|
||||
public interface ITestRunDataHolder
|
||||
{
|
||||
IList<TestRunData> TestRunDataList { get; }
|
||||
}
|
||||
|
||||
[Obsolete("No longer in use")]
|
||||
public class TestRunDataHolder: ScriptableSingleton<TestRunDataHolder>, ISerializationCallbackReceiver, ITestRunDataHolder
|
||||
{
|
||||
[SerializeField]
|
||||
private TestRunData[] TestRunData;
|
||||
public IList<TestRunData> TestRunDataList { get; private set; } = new List<TestRunData>();
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
TestRunData = TestRunDataList.ToArray();
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
TestRunDataList = TestRunData.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dc341f3ffc346738912e0ae5aa6c7e4
|
||||
timeCreated: 1699443220
|
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestRunner.UnityTestProtocol
|
||||
{
|
||||
[Serializable]
|
||||
public class TestRunData
|
||||
{
|
||||
public string SuiteName;
|
||||
public string[] TestsInFixture;
|
||||
public long OneTimeSetUpDuration;
|
||||
public long OneTimeTearDownDuration;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fc9f45e5db884c07b28ac7207622a4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEditor.TestTools.TestRunner.GUI;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class TestRunnerApiMapper : ITestRunnerApiMapper
|
||||
{
|
||||
internal IGuiHelper guiHelper = new GuiHelper(new MonoCecilHelper(), new AssetsDatabaseHelper());
|
||||
private readonly string _projectRepoPath;
|
||||
|
||||
public TestRunnerApiMapper(string projectRepoPath)
|
||||
{
|
||||
_projectRepoPath = projectRepoPath;
|
||||
}
|
||||
|
||||
public TestPlanMessage MapTestToTestPlanMessage(ITestAdaptor testsToRun)
|
||||
{
|
||||
var testsNames = testsToRun != null ? FlattenTestNames(testsToRun) : new List<string>();
|
||||
|
||||
var msg = new TestPlanMessage
|
||||
{
|
||||
tests = testsNames
|
||||
};
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
public TestStartedMessage MapTestToTestStartedMessage(ITestAdaptor test)
|
||||
{
|
||||
return new TestStartedMessage
|
||||
{
|
||||
name = test.FullName
|
||||
};
|
||||
}
|
||||
|
||||
public TestFinishedMessage TestResultToTestFinishedMessage(ITestResultAdaptor result)
|
||||
{
|
||||
string filePathString = default;
|
||||
int lineNumber = default;
|
||||
if (result.Test.Method != null && result.Test.TypeInfo != null)
|
||||
{
|
||||
var method = result.Test.Method.MethodInfo;
|
||||
var type = result.Test.TypeInfo.Type;
|
||||
var fileOpenInfo = guiHelper.GetFileOpenInfo(type, method);
|
||||
filePathString = !string.IsNullOrEmpty(_projectRepoPath) ? Path.Combine(_projectRepoPath, fileOpenInfo.FilePath) : fileOpenInfo.FilePath;
|
||||
lineNumber = fileOpenInfo.LineNumber;
|
||||
}
|
||||
|
||||
var iteration = 0;
|
||||
if(result is TestResultAdaptor)
|
||||
{
|
||||
var adaptor = ((TestResultAdaptor)result);
|
||||
iteration = adaptor.RepeatIteration == 0 ? adaptor.RetryIteration : adaptor.RepeatIteration;
|
||||
}
|
||||
return new TestFinishedMessage
|
||||
{
|
||||
name = result.Test.FullName,
|
||||
duration = Convert.ToUInt64(result.Duration * 1000),
|
||||
durationMicroseconds = Convert.ToUInt64(result.Duration * 1000000),
|
||||
message = result.Message,
|
||||
state = GetTestStateFromResult(result),
|
||||
stackTrace = result.StackTrace,
|
||||
fileName = filePathString,
|
||||
lineNumber = lineNumber,
|
||||
iteration = iteration
|
||||
};
|
||||
}
|
||||
|
||||
public string GetRunStateFromResultNunitXml(ITestResultAdaptor result)
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
doc.LoadXml(result.ToXml().OuterXml);
|
||||
return doc.FirstChild.Attributes["runstate"].Value;
|
||||
}
|
||||
|
||||
public TestState GetTestStateFromResult(ITestResultAdaptor result)
|
||||
{
|
||||
var state = TestState.Failure;
|
||||
|
||||
if (result.TestStatus == TestStatus.Passed)
|
||||
{
|
||||
state = TestState.Success;
|
||||
}
|
||||
else if (result.TestStatus == TestStatus.Skipped)
|
||||
{
|
||||
state = TestState.Skipped;
|
||||
|
||||
if (result.ResultState.ToLowerInvariant().EndsWith("ignored"))
|
||||
{
|
||||
state = TestState.Ignored;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.ResultState.ToLowerInvariant().Equals("inconclusive"))
|
||||
{
|
||||
state = TestState.Inconclusive;
|
||||
}
|
||||
|
||||
if (result.ResultState.ToLowerInvariant().EndsWith("cancelled") ||
|
||||
result.ResultState.ToLowerInvariant().EndsWith("error"))
|
||||
{
|
||||
state = TestState.Error;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public List<string> FlattenTestNames(ITestAdaptor test)
|
||||
{
|
||||
var results = new List<string>();
|
||||
|
||||
if (!test.IsSuite)
|
||||
results.Add(test.FullName);
|
||||
|
||||
if (test.Children != null && test.Children.Any())
|
||||
foreach (var child in test.Children)
|
||||
results.AddRange(FlattenTestNames(child));
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2011a59d3f76b3d4a85cb53f945fceee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
// This matches the state definitions expected by the Perl code, which in turn matches the NUnit 2 values...
|
||||
internal enum TestState
|
||||
{
|
||||
Inconclusive = 0,
|
||||
Skipped = 2,
|
||||
Ignored = 3,
|
||||
Success = 4,
|
||||
Failure = 5,
|
||||
Error = 6
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77f432980bb30084299a138e15c6f571
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using UnityEditor.TestTools.TestRunner.Api;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
|
||||
{
|
||||
internal class UnityTestProtocolListener : ICallbacks
|
||||
{
|
||||
private IUtpMessageReporter m_UtpMessageReporter;
|
||||
|
||||
public UnityTestProtocolListener(string projectPath)
|
||||
{
|
||||
m_UtpMessageReporter = new UtpMessageReporter(new UtpDebugLogger(), projectPath);
|
||||
}
|
||||
|
||||
public void RunStarted(ITestAdaptor testsToRun)
|
||||
{
|
||||
m_UtpMessageReporter.ReportTestRunStarted(testsToRun);
|
||||
}
|
||||
|
||||
public void RunFinished(ITestResultAdaptor testResults)
|
||||
{
|
||||
// Apparently does nothing :)
|
||||
}
|
||||
|
||||
public void TestStarted(ITestAdaptor test)
|
||||
{
|
||||
m_UtpMessageReporter.ReportTestStarted(test);
|
||||
}
|
||||
|
||||
public void TestFinished(ITestResultAdaptor result)
|
||||
{
|
||||
m_UtpMessageReporter.ReportTestFinished(result);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 900aac3710bc14542a8d164e3f0ff820
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,42 @@
|
||||
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();
|
||||
//Ensuring that it is used only when tests are run using UTR.
|
||||
if (IsEnabled())
|
||||
{
|
||||
var api = ScriptableObject.CreateInstance<TestRunnerApi>();
|
||||
var listener = new UnityTestProtocolListener(GetRepositoryPath(commandLineArgs));
|
||||
api.RegisterCallbacks(listener);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsEnabled()
|
||||
{
|
||||
var commandLineArgs = Environment.GetCommandLineArgs();
|
||||
return commandLineArgs.Contains("-automated") && commandLineArgs.Contains("-runTests");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ac58cb55fc8daf4abd3945a2bbbb0c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user