コード例 #1
0
ファイル: TestBase.cs プロジェクト: xd2006/TLMTestProject
        private void ProcessFailedCaseWithTestRail(List <object> testCaseNumbers, APIClient client)
        {
            if (testCaseNumbers.Count > 0)
            {
                if (client != null)
                {
                    foreach (var testCase in testCaseNumbers)
                    {
                        try
                        {
                            if (TestContext.CurrentContext.Test.Properties["Category"].Contains("Blocked"))
                            {
                                string reason = TestContext.CurrentContext.Test.Properties.ContainsKey("Reason")
                                                    ? TestContext.CurrentContext.Test.Properties.Get("Reason").ToString()
                                                    : "Blocking reason is not set.";
                                client.BlockCase(Parameters.Parameters.TestRailRunId, testCase.ToString(), reason);
                            }
                            else
                            {
                                string bugsList = string.Empty;
                                if (TestContext.CurrentContext.Test.Properties.ContainsKey("Bug"))
                                {
                                    bugsList = TestContext.CurrentContext.Test.Properties.Get("Bug").ToString();
                                }

                                client.FailCase(
                                    Parameters.Parameters.TestRailRunId,
                                    testCase.ToString(),
                                    $"Test method: {TestContext.CurrentContext.Test.MethodName}, Result message: {TestContext.CurrentContext.Result.Message}",
                                    bugsList);
                            }
                        }
                        catch (Exception e)
                        {
                            // supress exception
                            this.App.Logger.Warn($"Can't update test cases '{testCase}' state on TestRail:");
                            this.App.Logger.Warn(e.Message);
                        }
                    }
                }
            }
        }