forked from microsoft/testfx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestResultExtensions.cs
More file actions
59 lines (51 loc) · 2.83 KB
/
Copy pathTestResultExtensions.cs
File metadata and controls
59 lines (51 loc) · 2.83 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
58
59
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Extensions
{
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
using UTF = Microsoft.VisualStudio.TestTools.UnitTesting;
public static class TestResultExtensions
{
/// <summary>
/// Converts the test framework's TestResult objects array to a serializable UnitTestResult objects array.
/// </summary>
/// <param name="testResults">The test framework's TestResult object array.</param>
/// <returns>The serializable UnitTestResult object array.</returns>
public static UnitTestResult[] ToUnitTestResults(this UTF.TestResult[] testResults)
{
UnitTestResult[] unitTestResults = new UnitTestResult[testResults.Length];
for (int i = 0; i < testResults.Length; ++i)
{
UnitTestResult unitTestResult = null;
UnitTestOutcome outcome = testResults[i].Outcome.ToUnitTestOutcome();
if (testResults[i].TestFailureException != null)
{
TestFailedException testException = testResults[i].TestFailureException as TestFailedException;
unitTestResult =
new UnitTestResult(
new TestFailedException(
outcome,
testResults[i].TestFailureException.TryGetMessage(),
testException != null ? testException.StackTraceInformation : testResults[i].TestFailureException.TryGetStackTraceInformation()));
}
else
{
unitTestResult = new UnitTestResult { Outcome = outcome };
}
unitTestResult.StandardOut = testResults[i].LogOutput;
unitTestResult.StandardError = testResults[i].LogError;
unitTestResult.DebugTrace = testResults[i].DebugTrace;
unitTestResult.TestContextMessages = testResults[i].TestContextMessages;
unitTestResult.Duration = testResults[i].Duration;
unitTestResult.DisplayName = testResults[i].DisplayName;
unitTestResult.DatarowIndex = testResults[i].DatarowIndex;
unitTestResult.ResultFiles = testResults[i].ResultFiles;
unitTestResult.ExecutionId = testResults[i].ExecutionId;
unitTestResult.ParentExecId = testResults[i].ParentExecId;
unitTestResult.InnerResultsCount = testResults[i].InnerResultsCount;
unitTestResults[i] = unitTestResult;
}
return unitTestResults;
}
}
}