Пример #1
0
        public ulong?GetTestRun()
        {
            Project project  = null;
            Run     run      = null;
            var     projects = _client.GetProjects();

            if (projects.Count == 0)
            {
                Console.WriteLine("An error occurred while getting the list of projects from TestRail. " +
                                  "Check the availability of TestRail from the current environment.");
            }
            try
            {
                project = projects.First(p => p.Name == _config.ProjectName);
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine($"The ProjectName '{_config.ProjectName}' from the TestRail.json file was not found in the project list. " +
                                  "Please check that the ProjectName is correct.");
                throw e;
            }
            var runs = _client.GetRuns(project.ID);

            try
            {
                run = runs.First(i => i.IsCompleted == false && Regex.IsMatch(i.Name, _config.RunNameTemplate));
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine($"Test run '{_config.RunNameTemplate}' from TestRail.json file not found. " +
                                  "Please make sure the template is correct.");
                throw e;
            }
            return(run.ID);
        }
Пример #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);
                     */
                }
            }
        }
 private Project getTestRailProject(string projectName)
 {
     return(_testRailClient.GetProjects().Find(x => x.Name.Equals(projectName)));
 }