From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../AssemblyCompilationErrorsMessage.cs | 13 +++ .../AssemblyCompilationErrorsMessage.cs.meta | 11 +++ .../UnityTestProtocol/ITestRunnerApiMapper.cs | 15 ++++ .../UnityTestProtocol/ITestRunnerApiMapper.cs.meta | 11 +++ .../UnityTestProtocol/IUtpLogger.cs | 7 ++ .../UnityTestProtocol/IUtpLogger.cs.meta | 11 +++ .../UnityTestProtocol/IUtpMessageReporter.cs | 14 +++ .../UnityTestProtocol/IUtpMessageReporter.cs.meta | 11 +++ .../UnityTestProtocol/Message.cs | 29 +++++++ .../UnityTestProtocol/Message.cs.meta | 11 +++ .../UnityTestProtocol/TestFinishedMessage.cs | 18 ++++ .../UnityTestProtocol/TestFinishedMessage.cs.meta | 11 +++ .../UnityTestProtocol/TestPlanMessage.cs | 14 +++ .../UnityTestProtocol/TestPlanMessage.cs.meta | 11 +++ .../UnityTestProtocol/TestRunnerApiMapper.cs | 99 ++++++++++++++++++++++ .../UnityTestProtocol/TestRunnerApiMapper.cs.meta | 11 +++ .../UnityTestProtocol/TestStartedMessage.cs | 15 ++++ .../UnityTestProtocol/TestStartedMessage.cs.meta | 11 +++ .../UnityTestProtocol/TestState.cs | 13 +++ .../UnityTestProtocol/TestState.cs.meta | 11 +++ .../UnityTestProtocol/UnityTestProtocolListener.cs | 35 ++++++++ .../UnityTestProtocolListener.cs.meta | 11 +++ .../UnityTestProtocol/UnityTestProtocolStarter.cs | 37 ++++++++ .../UnityTestProtocolStarter.cs.meta | 11 +++ .../UnityTestProtocol/UtpDebuglogger.cs | 13 +++ .../UnityTestProtocol/UtpDebuglogger.cs.meta | 11 +++ .../UnityTestProtocol/UtpMessageReporter.cs | 57 +++++++++++++ .../UnityTestProtocol/UtpMessageReporter.cs.meta | 11 +++ 28 files changed, 533 insertions(+) create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs.meta (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol') diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs new file mode 100644 index 0000000..8ed6b3c --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs @@ -0,0 +1,13 @@ +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + internal class AssemblyCompilationErrorsMessage : Message + { + public string assembly; + public string[] errors; + + public AssemblyCompilationErrorsMessage() + { + type = "AssemblyCompilationErrors"; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs.meta new file mode 100644 index 0000000..8c0fea1 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/AssemblyCompilationErrorsMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c346a7445959bba46a96de0747e77c2a +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/UnityTestProtocol/ITestRunnerApiMapper.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs new file mode 100644 index 0000000..231fe4b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs @@ -0,0 +1,15 @@ +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 FlattenTestNames(ITestAdaptor testsToRun); + TestPlanMessage MapTestToTestPlanMessage(ITestAdaptor testsToRun); + TestStartedMessage MapTestToTestStartedMessage(ITestAdaptor test); + TestFinishedMessage TestResultToTestFinishedMessage(ITestResultAdaptor result); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs.meta new file mode 100644 index 0000000..af6635c --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/ITestRunnerApiMapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6de79ae237e51554da96fd28f68b66a6 +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/UnityTestProtocol/IUtpLogger.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs new file mode 100644 index 0000000..4d7fb71 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs @@ -0,0 +1,7 @@ +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + interface IUtpLogger + { + void Log(Message msg); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs.meta new file mode 100644 index 0000000..82b7277 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpLogger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9014630255533ed42915965b4065cde8 +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/UnityTestProtocol/IUtpMessageReporter.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs new file mode 100644 index 0000000..c134615 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs @@ -0,0 +1,14 @@ +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 errorCompilerMessages); + void ReportTestFinished(ITestResultAdaptor result); + void ReportTestRunStarted(ITestAdaptor testsToRun); + void ReportTestStarted(ITestAdaptor test); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs.meta new file mode 100644 index 0000000..d966c9a --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/IUtpMessageReporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 952b3dc7b47846947b37c8d3ae46579a +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/UnityTestProtocol/Message.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs new file mode 100644 index 0000000..a654b7e --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs @@ -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); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs.meta new file mode 100644 index 0000000..6f55024 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/Message.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 321dc2c0720f8dd4f9396ecdc12b8746 +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/UnityTestProtocol/TestFinishedMessage.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs new file mode 100644 index 0000000..63d7daf --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs @@ -0,0 +1,18 @@ +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"; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs.meta new file mode 100644 index 0000000..581ee84 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestFinishedMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 423fe2ef878fa1140a7e1f7f9e365815 +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/UnityTestProtocol/TestPlanMessage.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs new file mode 100644 index 0000000..7e4ea41 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + internal class TestPlanMessage : Message + { + public List tests; + + public TestPlanMessage() + { + type = "TestPlan"; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs.meta new file mode 100644 index 0000000..5dcc09d --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestPlanMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28f79a0d7e64c2345bc46f8c4cf788f8 +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/UnityTestProtocol/TestRunnerApiMapper.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs new file mode 100644 index 0000000..494646f --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs @@ -0,0 +1,99 @@ +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(); + + 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 FlattenTestNames(ITestAdaptor test) + { + var results = new List(); + + 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; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs.meta new file mode 100644 index 0000000..619f384 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2011a59d3f76b3d4a85cb53f945fceee +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/UnityTestProtocol/TestStartedMessage.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs new file mode 100644 index 0000000..7a878a6 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs @@ -0,0 +1,15 @@ +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + internal class TestStartedMessage : Message + { + public string name; + public TestState state; + + public TestStartedMessage() + { + type = "TestStatus"; + phase = "Begin"; + state = TestState.Inconclusive; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs.meta new file mode 100644 index 0000000..28492e7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestStartedMessage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd3e81baa10021f4d877fa36382bab16 +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/UnityTestProtocol/TestState.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs new file mode 100644 index 0000000..111813a --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs @@ -0,0 +1,13 @@ +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 + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs.meta new file mode 100644 index 0000000..125e419 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 77f432980bb30084299a138e15c6f571 +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/UnityTestProtocol/UnityTestProtocolListener.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs new file mode 100644 index 0000000..8ba3d7f --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs @@ -0,0 +1,35 @@ +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); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs.meta new file mode 100644 index 0000000..e369442 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 900aac3710bc14542a8d164e3f0ff820 +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/UnityTestProtocol/UnityTestProtocolStarter.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs new file mode 100644 index 0000000..8d16ca5 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs @@ -0,0 +1,37 @@ +using System; +using System.Linq; +using UnityEditor.Compilation; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + [InitializeOnLoad] + internal static class UnityTestProtocolStarter + { + static UnityTestProtocolStarter() + { + var commandLineArgs = Environment.GetCommandLineArgs(); + if (commandLineArgs.Contains("-automated") && commandLineArgs.Contains("-runTests")) // wanna have it only for utr run + { + var api = ScriptableObject.CreateInstance(); + var listener = ScriptableObject.CreateInstance(); + api.RegisterCallbacks(listener); + CompilationPipeline.assemblyCompilationFinished += OnAssemblyCompilationFinished; + } + } + + public static void OnAssemblyCompilationFinished(string assembly, CompilerMessage[] messages) + { + bool checkCompileErrors = RecompileScripts.Current == null || RecompileScripts.Current.ExpectScriptCompilationSuccess; + + if (checkCompileErrors && messages.Any(x => x.type == CompilerMessageType.Error)) + { + var compilerErrorMessages = messages.Where(x => x.type == CompilerMessageType.Error); + var utpMessageReporter = new UtpMessageReporter(new UtpDebugLogger()); + utpMessageReporter.ReportAssemblyCompilationErrors(assembly, compilerErrorMessages); + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs.meta new file mode 100644 index 0000000..8d65f46 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UnityTestProtocolStarter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ac58cb55fc8daf4abd3945a2bbbb0c5 +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/UnityTestProtocol/UtpDebuglogger.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs new file mode 100644 index 0000000..537e350 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + class UtpDebugLogger : IUtpLogger + { + public void Log(Message msg) + { + var msgJson = JsonUtility.ToJson(msg); + Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, "\n##utp:{0}", msgJson); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs.meta new file mode 100644 index 0000000..eb25630 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpDebuglogger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d0abdd8cb6b29a24c8ee19626ef741b9 +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/UnityTestProtocol/UtpMessageReporter.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs new file mode 100644 index 0000000..22450c8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEditor.Compilation; +using UnityEditor.TestTools.TestRunner.Api; + +namespace UnityEditor.TestTools.TestRunner.UnityTestProtocol +{ + internal class UtpMessageReporter : IUtpMessageReporter + { + public ITestRunnerApiMapper TestRunnerApiMapper; + public IUtpLogger Logger; + + public UtpMessageReporter(IUtpLogger utpLogger) + { + TestRunnerApiMapper = new TestRunnerApiMapper(); + Logger = utpLogger; + } + + public void ReportAssemblyCompilationErrors(string assembly, IEnumerable errorCompilerMessages) + { + var compilationErrorMessage = new AssemblyCompilationErrorsMessage + { + assembly = assembly, + errors = errorCompilerMessages.Select(x => x.message).ToArray() + }; + + Logger.Log(compilationErrorMessage); + } + + public void ReportTestRunStarted(ITestAdaptor testsToRun) + { + var msg = TestRunnerApiMapper.MapTestToTestPlanMessage(testsToRun); + + Logger.Log(msg); + } + + public void ReportTestStarted(ITestAdaptor test) + { + if (test.IsSuite) + return; + + var msg = TestRunnerApiMapper.MapTestToTestStartedMessage(test); + + Logger.Log(msg); + } + + public void ReportTestFinished(ITestResultAdaptor result) + { + if (result.Test.IsSuite) + return; + + var msg = TestRunnerApiMapper.TestResultToTestFinishedMessage(result); + + Logger.Log(msg); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs.meta new file mode 100644 index 0000000..02cccdf --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageReporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ebcc5f899d9277642868aeda9a17cbaf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.2.3