UtpMessageReporter.cs
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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<CompilerMessage> 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);
}
}
}