summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-20 19:09:33 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-20 19:09:33 -0400
commit7c1e566113d59699af1624186c64eca67f063fc6 (patch)
tree5a6850a695986872d5d0b09d7dab8421628fe33e /Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs
parentdd117b77aae1d8be7563b360d05b842a73b7dab2 (diff)
downloadProject-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.tar.gz
Project-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.tar.bz2
Project-Sandbox-7c1e566113d59699af1624186c64eca67f063fc6.zip
Upgraded Unity
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs')
-rw-r--r--Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs99
1 files changed, 0 insertions, 99 deletions
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
deleted file mode 100644
index 494646f..0000000
--- a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/UnityTestProtocol/TestRunnerApiMapper.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-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;
- }
- }
-}