コード例 #1
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)
            {
            }
        }
コード例 #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            var client   = new TestRailClient("https://accela.testrail.net/", "*****@*****.**", "Change_2017");
            var projects = client.GetProjects();

            foreach (var project in projects)
            {
                if (project.Name == "Accela 9.2.0&9.1.X Test Execution")
                {
                    var plans = client.GetPlans(project.ID);
                    foreach (var plan in plans)
                    {
                        if (plan.Name == "Accela Automation 9.2.0 Release")
                        {
                            var testPlan = client.GetPlan(plan.ID);
                            foreach (var entry in testPlan.Entries)
                            {
                                if (entry.Name == "9.1.2 Code Merge to 9.2.0")
                                {
                                    foreach (var run in entry.RunList)
                                    {
                                        if (run.Name == "9.1.2 Code Merge to 9.2.0")
                                        {
                                            var testcases = client.GetTests((ulong)run.ID);
                                            foreach (var testcase in testcases)
                                            {
                                                var results = client.GetResultsForCase((ulong)run.ID, (ulong)testcase.CaseID);
                                            }

                                            /*
                                             * var results = client.GetResultsForRun((ulong)run.ID);
                                             * foreach(var result in results)
                                             * {
                                             *  var testcase = client.GetTest(result.TestID);
                                             *
                                             *  var testcaseInfo = testcase.JsonFromResponse;
                                             *  testcaseInfo.GetValue("");
                                             * }
                                             */
                                        }
                                    }
                                }
                            }
                        }
                    }

                    /*
                     * var milestomes = client.GetMilestones(project.ID);
                     *
                     * foreach (var milestone in milestomes)
                     * {
                     *  if (milestone.Name == "Accela Automation 9.2.0 Release")
                     *  {
                     *  }
                     * }
                     *
                     * var runs = client.GetRuns(project.ID);
                     */
                }
            }
        }