/// <summary> /// Method for getting all the RunIDs for a specific Project and Specific to Milestone /// </summary> /// <param name="MilestoneId"></param> /// <returns></returns> public List <string> GetRunIdsForProjectAndMileStone(String MilestoneId) { string ProjectId = GetProjectID(); Gurock.TestRail.APIClient client = GetTestRailClientConfig(); JArray response = null; List <string> runs = new List <string>(); try { response = (JArray)client.SendGet("get_runs/" + ProjectId); for (int i = 0; i < response.LongCount(); i++) { JObject sections = (JObject)response.ElementAt(i); Object milestone_id = sections.GetValue("milestone_id"); if (milestone_id != null) { if (sections.GetValue("milestone_id").ToString().Equals(MilestoneId)) { runs.Add(sections.GetValue("id").ToString()); continue; } } } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(runs); }
/// <summary> /// Method for getting all the Test Cases for a Project for all the suites /// </summary> /// <returns></returns> public Dictionary <string, string> GetAllTestCasesFromAllSuites() { Gurock.TestRail.APIClient client = GetTestRailClientConfig(); string ProjectId = GetProjectID(); List <string> SuiteIds = GetAllSuiteIds(); Dictionary <string, string> AllTestCases = new Dictionary <string, string>(); try { foreach (string SuiteId in SuiteIds) { _testRailUtilsLog.Info("===fetching test cases for suite:=>" + SuiteId); JArray response = (JArray)client.SendGet("get_cases/" + ProjectId + "&suite_id=" + SuiteId); for (int i = 0; i < response.LongCount(); i++) { JObject Case = (JObject)response.ElementAt(i); AllTestCases.Add(Case.GetValue("id").ToString(), Case.GetValue("title").ToString()); } } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(AllTestCases); }
/// <summary> /// Method for getting All the test cases which is under a Project and a Suite /// </summary> /// <returns>Dictionary<string,string></returns> public Dictionary <string, string> GetAllTestCases() { Gurock.TestRail.APIClient client = GetTestRailClientConfig(); string ProjectId = GetProjectID(); string SuiteId = GetSuiteId(); Dictionary <string, string> AllTestCases = new Dictionary <string, string>(); JArray response = (JArray)client.SendGet("get_cases/" + ProjectId + "&suite_id=" + SuiteId); for (int i = 0; i < response.LongCount(); i++) { JObject Case = (JObject)response.ElementAt(i); AllTestCases.Add(Case.GetValue("id").ToString(), Case.GetValue("title").ToString()); } return(AllTestCases); }
/// <summary> /// Method for getting all the TestRuns for Certain ProjectID /// </summary> /// <param name="ProjectId"></param> /// <returns></returns> public Dictionary <string, string> GetAllRunsForAProject(string ProjectId) { Gurock.TestRail.APIClient client = GetTestRailClientConfig(); Dictionary <string, string> AllRuns = new Dictionary <string, string>(); try { JArray response = (JArray)client.SendGet("get_runs/" + ProjectId + ""); for (int i = 0; i < response.LongCount(); i++) { JObject Run = (JObject)response.ElementAt(i); AllRuns.Add(Run.GetValue("id").ToString(), Run.GetValue("name").ToString()); } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(AllRuns); }
/// <summary> /// Method for all the Projects Name and their unique IDs for TestRail Client. /// </summary> /// <returns></returns> public Dictionary <string, string> GetAllProjects() { Gurock.TestRail.APIClient client = GetTestRailClientConfig(); Dictionary <string, string> AllProjects = new Dictionary <string, string>(); try { JArray response = (JArray)client.SendGet("get_projects"); for (int i = 0; i < response.LongCount(); i++) { JObject project = (JObject)response.ElementAt(i); AllProjects.Add(project.GetValue("id").ToString(), project.GetValue("name").ToString()); } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(AllProjects); }
/// <summary> /// Method for getting all the Test Case IDs for a particular Test Run /// </summary> /// <param name="RunId"></param> /// <returns></returns> public List <String> getCaseIdsForRun(String RunId) { Gurock.TestRail.APIClient client = GetTestRailClientConfig(); List <String> caseIds = new List <String>(); JArray response = null; try { response = (JArray)client.SendGet("get_tests/" + RunId); for (int i = 0; i < response.LongCount(); i++) { JObject obj = (JObject)response.ElementAt(i); caseIds.Add(obj.GetValue("case_id").ToString()); } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(caseIds); }
/// <summary> /// Method for getting all the MileStones for a specific Project /// </summary> /// <returns></returns> public Dictionary <string, string> GetAllMilestones() { string ProjectId = GetProjectID(); Gurock.TestRail.APIClient client = GetTestRailClientConfig(); Dictionary <string, string> milestones = new Dictionary <string, string>(); JArray response = null; try { response = (JArray)client.SendGet("get_milestones/" + ProjectId); for (int i = 0; i < response.LongCount(); i++) { JObject suite = (JObject)response.ElementAt(i); milestones.Add(suite.GetValue("id").ToString(), suite.GetValue("name").ToString()); } } catch (Exception ex) { _testRailUtilsLog.Error(ex); } return(milestones); }