Skip to content

Commit 5580399

Browse files
committed
Fixed issue with test outcomes "Skipped" and "NotFound", which would otherwise return 400 (Bad Request)
1 parent 04e8055 commit 5580399

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

src/AzurePipelines.TestLogger/ApiClient.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,33 @@ public async Task MarkTestRunCompleted(int testRunId, DateTime startedDate, Date
159159

160160
protected Dictionary<string, object> GetTestResultProperties(ITestResult testResult)
161161
{
162+
// https://docs.microsoft.com/en-us/rest/api/azure/devops/test/results/list?view=azure-devops-rest-6.0#testcaseresult
163+
// outcome valid values = (Unspecified, None, Passed, Failed, Inconclusive, Timeout, Aborted, Blocked, NotExecuted, Warning, Error, NotApplicable, Paused, InProgress, NotImpacted)
164+
string testOutcome;
165+
switch (testResult.Outcome)
166+
{
167+
case TestOutcome.None:
168+
testOutcome = "None";
169+
break;
170+
case TestOutcome.Passed:
171+
testOutcome = "Passed";
172+
break;
173+
case TestOutcome.Failed:
174+
testOutcome = "Failed";
175+
break;
176+
case TestOutcome.Skipped:
177+
testOutcome = "Inconclusive";
178+
break;
179+
case TestOutcome.NotFound:
180+
testOutcome = "NotExecuted";
181+
break;
182+
default:
183+
throw new ArgumentOutOfRangeException(nameof(testResult.Outcome), testResult.Outcome.ToString());
184+
}
185+
162186
Dictionary<string, object> properties = new Dictionary<string, object>
163187
{
164-
{ "outcome", testResult.Outcome.ToString() },
188+
{ "outcome", testOutcome },
165189
{ "computerName", testResult.ComputerName },
166190
{ "runBy", new Dictionary<string, object> { { "displayName", BuildRequestedFor } } }
167191
};

0 commit comments

Comments
 (0)