-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathUnitTestOutcomeHelper.cs
29 lines (25 loc) · 1.51 KB
/
UnitTestOutcomeHelper.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using UTF = Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers;
internal static class UnitTestOutcomeHelper
{
/// <summary>
/// Converts the parameter unitTestOutcome to testOutcome.
/// </summary>
/// <param name="unitTestOutcome"> The unit Test Outcome. </param>
/// <param name="currentSettings">Current MSTest settings.</param>
/// <returns>The Test platforms outcome.</returns>
internal static TestOutcome ToTestOutcome(UTF.UnitTestOutcome unitTestOutcome, MSTestSettings currentSettings)
=> unitTestOutcome switch
{
UTF.UnitTestOutcome.Passed => TestOutcome.Passed,
UTF.UnitTestOutcome.Failed or UTF.UnitTestOutcome.Error or UTF.UnitTestOutcome.Timeout or UTF.UnitTestOutcome.Aborted or UTF.UnitTestOutcome.Unknown => TestOutcome.Failed,
UTF.UnitTestOutcome.NotRunnable => currentSettings.MapNotRunnableToFailed ? TestOutcome.Failed : TestOutcome.None,
UTF.UnitTestOutcome.Ignored => TestOutcome.Skipped,
UTF.UnitTestOutcome.Inconclusive => currentSettings.MapInconclusiveToFailed ? TestOutcome.Failed : TestOutcome.Skipped,
UTF.UnitTestOutcome.NotFound => TestOutcome.NotFound,
_ => TestOutcome.None,
};
}