private Run addTestRailRun(Project testRailProject, Milestone milestone, TestSuite testSuite)
        {
            var commandResult = _testRailClient.AddRun(testRailProject.ID, Convert.ToUInt32(testSuite.UserID),
                                                       $"{testSuite.Title} (S{testSuite.UserID}) - {DateTime.Now}", testSuite.Description, milestone.ID);

            return(_testRailClient.GetRun(commandResult.Value));
        }
示例#2
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            var testRunUrl = this.txtTestRunUrl.Text;

            if (testRunUrl.StartsWith("https://accela.testrail.net/index.php?/runs/view/") == false)
            {
                MessageBox.Show("The format of test run url should be https://accela.testrail.net/index.php?/runs/view/XXXX");
                return;
            }

            testRunUrl = testRunUrl.Remove(0, "https://accela.testrail.net/index.php?/runs/view/".Length);
            var testRunID = testRunUrl.IndexOf("&") > 0 ? ulong.Parse(testRunUrl.Substring(0, testRunUrl.IndexOf("&"))) : ulong.Parse(testRunUrl);

            var client    = new TestRailClient("https://accela.testrail.net/", "*****@*****.**", "Change_2017");
            var testRun   = client.GetRun((ulong)testRunID);
            var testcases = client.GetTests((ulong)testRunID);

            List <TestResult> testResults = new List <TestResult>();

            foreach (var testcase in testcases)
            {
                var        testcaseFields = JsonConvert.DeserializeObject <TestCaseFields>(testcase.JsonFromResponse.ToString());
                TestResult testResult     = new TestResult();
                testResult.JiraKey       = testcaseFields.JiraKey;
                testResult.TestRunID     = testRunID;
                testResult.TestRunTitle  = testRun.Name;
                testResult.TestRunUrl    = testRun.Url;
                testResult.TestCaseID    = testcase.CaseID;
                testResult.TestCaseTitle = testcase.Title;
                testResult.Status        = testcase.Status.ToString();
                testResult.AssignedTo    = testcase.AssignedToID != null ? TestrailUserDic[(ulong)testcase.AssignedToID].Name : "";
                //testResult.LastUpdateTime =

                var results = client.GetResultsForCase((ulong)testRunID, (ulong)testcase.CaseID);
                foreach (var result in results)
                {
                    testResult.AssignedTo     = TestrailUserDic[(ulong)result.CreatedBy].Name;
                    testResult.LastUpdateTime = result.CreatedOn;
                    break;
                }

                testResults.Add(testResult);
            }

            foreach (var testResult in testResults)
            {
            }
        }
示例#3
0
        public void AddResultToCollection(ulong?runId, CaseResult caseResult)
        {
            if (runId == null)
            {
                return;
            }
            if (caseResult.CaseId == null && !string.IsNullOrEmpty(caseResult.Title))
            {
                var run   = _client.GetRun(runId.Value);
                var cases = _client.GetCases(run.ProjectID.Value, run.SuiteID.Value);
                var @case = cases.FirstOrDefault(i => i.Title == caseResult.Title);
                caseResult.CaseId = @case?.ID;
            }

            if (caseResult.CaseId == null)
            {
                return;
            }
            // Do not override Failed test result with Passed status
            AddToCollection(caseResult.CaseId.Value, caseResult);
        }