/// <summary> /// Completes automation provider test run results, if any were missed or bypassed. /// </summary> /// <param name="testRun">Rhino.Api.Contracts.AutomationProvider.RhinoTestRun results object to complete by.</param> public override void CompleteTestRun(RhinoTestRun testRun) { // exit conditions if (Configuration.IsDryRun()) { return; } // setup: failed to update var inStatus = new[] { "TODO", "EXECUTING" }; // get all test keys to re-assign outcome var testResults = testRun .GetTests() .Where(i => inStatus.Contains($"{i["status"]}")) .Select(i => $"{i["key"]}"); // iterate: pass/fail foreach (var testCase in testRun.TestCases.Where(i => testResults.Contains(i.Key) && !i.Inconclusive)) { DoUpdateTestResult(testCase, inline: false); } // iterate: align all runs var dataTests = testRun.TestCases.Where(i => i.Iteration > 0).Select(i => i.Key).Distinct(); var options = new ParallelOptions { MaxDegreeOfParallelism = 1 }; Parallel.ForEach(dataTests, options, testCase => { var outcome = testRun.TestCases.Any(i => i.Key.Equals(testCase) && !i.Actual) ? "FAIL" : "PASS"; if (outcome == "FAIL") { testRun.TestCases.FirstOrDefault(i => !i.Actual && i.Key.Equals(testCase))?.SetOutcomeByRun(outcome); return; } testRun.TestCases.FirstOrDefault(i => i.Actual && i.Key.Equals(testCase))?.SetOutcomeByRun(outcome); }); // iterate: inconclusive foreach (var testCase in testRun.TestCases.Where(i => i.Inconclusive)) { DoUpdateTestResult(testCase, inline: true); } // test plan AttachToTestPlan(testRun); // close var comment = Utilities.GetActionSignature("closed"); jiraClient.CreateTransition(idOrKey: testRun.Key, transition: "Closed", resolution: "Done", comment); }