예제 #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);
        }