Commit af571a61 authored by BlackAngle233's avatar BlackAngle233
Browse files

212

parent 1d9b5391
using System.Collections.Generic;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
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);
}
}
using System.Collections.Generic;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
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);
}
}
fileFormatVersion: 2
guid: 6de79ae237e51554da96fd28f68b66a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6de79ae237e51554da96fd28f68b66a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
interface IUtpLogger
{
void Log(Message msg);
}
}
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
interface IUtpLogger
{
void Log(Message msg);
}
}
fileFormatVersion: 2
guid: 9014630255533ed42915965b4065cde8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9014630255533ed42915965b4065cde8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
using UnityEditor.Compilation;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal interface IUtpMessageReporter
{
void ReportAssemblyCompilationErrors(string assembly, IEnumerable<CompilerMessage> errorCompilerMessages);
void ReportTestFinished(ITestResultAdaptor result);
void ReportTestRunStarted(ITestAdaptor testsToRun);
void ReportTestStarted(ITestAdaptor test);
}
}
using System.Collections.Generic;
using UnityEditor.Compilation;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal interface IUtpMessageReporter
{
void ReportAssemblyCompilationErrors(string assembly, IEnumerable<CompilerMessage> errorCompilerMessages);
void ReportTestFinished(ITestResultAdaptor result);
void ReportTestRunStarted(ITestAdaptor testsToRun);
void ReportTestStarted(ITestAdaptor test);
}
}
fileFormatVersion: 2
guid: 952b3dc7b47846947b37c8d3ae46579a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 952b3dc7b47846947b37c8d3ae46579a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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);
}
}
}
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);
}
}
}
fileFormatVersion: 2
guid: 321dc2c0720f8dd4f9396ecdc12b8746
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 321dc2c0720f8dd4f9396ecdc12b8746
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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 TestFinishedMessage()
{
type = "TestStatus";
phase = "End";
}
}
}
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 TestFinishedMessage()
{
type = "TestStatus";
phase = "End";
}
}
}
fileFormatVersion: 2
guid: 423fe2ef878fa1140a7e1f7f9e365815
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 423fe2ef878fa1140a7e1f7f9e365815
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestPlanMessage : Message
{
public List<string> tests;
public TestPlanMessage()
{
type = "TestPlan";
}
}
}
using System.Collections.Generic;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestPlanMessage : Message
{
public List<string> tests;
public TestPlanMessage()
{
type = "TestPlan";
}
}
}
fileFormatVersion: 2
guid: 28f79a0d7e64c2345bc46f8c4cf788f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 28f79a0d7e64c2345bc46f8c4cf788f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestRunnerApiMapper : ITestRunnerApiMapper
{
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)
{
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
};
}
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;
var runstate = GetRunStateFromResultNunitXml(result);
runstate = runstate ?? String.Empty;
if (runstate.ToLowerInvariant().Equals("explicit"))
state = TestState.Skipped;
}
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;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestRunnerApiMapper : ITestRunnerApiMapper
{
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)
{
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
};
}
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;
var runstate = GetRunStateFromResultNunitXml(result);
runstate = runstate ?? String.Empty;
if (runstate.ToLowerInvariant().Equals("explicit"))
state = TestState.Skipped;
}
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;
}
}
}
fileFormatVersion: 2
guid: 2011a59d3f76b3d4a85cb53f945fceee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2011a59d3f76b3d4a85cb53f945fceee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestStartedMessage : Message
{
public string name;
public TestState state;
public TestStartedMessage()
{
type = "TestStatus";
phase = "Begin";
state = TestState.Inconclusive;
}
}
}
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class TestStartedMessage : Message
{
public string name;
public TestState state;
public TestStartedMessage()
{
type = "TestStatus";
phase = "Begin";
state = TestState.Inconclusive;
}
}
}
fileFormatVersion: 2
guid: bd3e81baa10021f4d877fa36382bab16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bd3e81baa10021f4d877fa36382bab16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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
}
}
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
}
}
fileFormatVersion: 2
guid: 77f432980bb30084299a138e15c6f571
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 77f432980bb30084299a138e15c6f571
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class UnityTestProtocolListener : ScriptableObject, ICallbacks
{
private IUtpMessageReporter m_UtpMessageReporter;
public UnityTestProtocolListener()
{
m_UtpMessageReporter = new UtpMessageReporter(new UtpDebugLogger());
}
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);
}
}
}
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol
{
internal class UnityTestProtocolListener : ScriptableObject, ICallbacks
{
private IUtpMessageReporter m_UtpMessageReporter;
public UnityTestProtocolListener()
{
m_UtpMessageReporter = new UtpMessageReporter(new UtpDebugLogger());
}
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);
}
}
}
fileFormatVersion: 2
guid: 900aac3710bc14542a8d164e3f0ff820
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 900aac3710bc14542a8d164e3f0ff820
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