// public static void OpenTestCase(TLSCmdletBase cmdlet, string name) // { // throw new NotImplementedException(); // } public static void AddBuild( TLSCmdletBase cmdlet, TestPlan[] testPlans, string buildName, string buildNote) { try { for (int j = 0; j < testPlans.Length; j++) { string description = string.Empty; if (null != buildNote && string.Empty != buildNote) { description = buildNote; } GeneralResult result = TLAddinData.CurrentTestLinkConnection.CreateBuild( testPlans[j].id, buildName, description); if (result.status) { cmdlet.WriteObject( cmdlet, TLAddinData.CurrentTestLinkConnection.GetLatestBuildForTestPlan(testPlans[j].id)); } } } catch (Exception eAddBuild) { cmdlet.WriteError( cmdlet, "Couldn't create a build '" + buildName + "'. " + eAddBuild.Message, "" + "CouldNotCreateBuild", ErrorCategory.InvalidResult, true); } }
/// <summary> /// get a test plan for a project /// </summary> /// <param name="projectname">the name of the owning project</param> /// <param name="planName"></param> /// <returns>a TestPlan or Null</returns> public TestPlan getTestPlanByName(string projectname, string planName) { stateIsValid(); object response = proxy.getTestPlanByName(devkey, projectname, planName); handleErrorMessage(response); object[] oList = response as object[]; if (oList.Length == 1) { XmlRpcStruct data = (XmlRpcStruct)oList[0]; if (data.ContainsKey("code")) { throw new TestLinkException("Testlink returned an error (code={0}, msg= {1})", data["code"], data["message"]); } TestPlan result = new TestPlan(data); return result; } return null; }
/// <summary> /// get a list of all testplans for a project /// </summary> /// <param name="projectid"></param> /// <returns></returns> public List<TestPlan> GetProjectTestPlans(int projectid) { List<TestPlan> retval = new List<TestPlan>(); object response = null; stateIsValid(); // Checked Testlink V 1.9.2 Still behaves this way try { response = proxy.getProjectTestPlans(devkey, projectid); // if a project has no test plans this exception is thrown } catch (CookComputing.XmlRpc.XmlRpcTypeMismatchException) { return retval; // empty list // happens when no plans exist. Empty response is sent back } catch (InvalidCastException) { return retval; // empty list } handleErrorMessage(response); if ((response is string) && ((string)response == string.Empty)) // equals null return return retval; XmlRpcStruct[] results = response as XmlRpcStruct[]; object[] oList = response as object[]; if ((oList.Length == 0) || (oList[0] is string)) return retval; foreach (XmlRpcStruct result in oList) { TestPlan tp = new TestPlan(result); retval.Add(tp); } return retval; }
internal static bool checkTestPlan(Meyn.TestLink.TestPlan[] inputObjects) { bool result = false; if (null == inputObjects) { if (null != TLAddinData.CurrentTestPlan) { inputObjects = new Meyn.TestLink.TestPlan[1]; inputObjects[0] = TLAddinData.CurrentTestPlan; result = true; } } return result; }
public static void GetBuild( TLSCmdletBase cmdlet, TestPlan[] testPlans, string[] buildNames) { string testPlanNameNow = string.Empty; WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; try { foreach (Meyn.TestLink.TestPlan testPlan in testPlans) { testPlanNameNow = testPlan.name; System.Collections.Generic.List<Meyn.TestLink.Build> buildsList = TLAddinData.CurrentTestLinkConnection.GetBuildsForTestPlan(testPlan.id); if (null == buildNames || 0 == buildNames.Length) { cmdlet.WriteObject( cmdlet, buildsList); } else { foreach (Meyn.TestLink.Build build in buildsList) { foreach (string buildName in buildNames) { if ((new WildcardPattern(buildName, options)).IsMatch(build.name)) { cmdlet.WriteObject( cmdlet, build); } } } } } } catch (Exception eGetBuild) { cmdlet.WriteError( cmdlet, "Couldn't get builds from '" + testPlanNameNow + "'. " + eGetBuild.Message, "" + "CouldNotGetBuild", ErrorCategory.InvalidResult, true); } }
/// <summary> /// find a testplan within the automated test project sandbox /// </summary> /// <param name="testPlanName"></param> /// <returns></returns> protected TestPlan getTestPlan(string testPlanName) { List<TestPlan> plans = proxy.GetProjectTestPlans(ApiTestProjectId); //Assert.IsNotEmpty(plans, "Setup failed, couldn't find testplans for project {0}", testProjectName); plan = null; foreach (TestPlan candidate in plans) if (candidate.name == testPlanName) { plan = candidate; break; } if (plan == null) Assert.Fail("Setup failed, could not find test plan named '{0}' in project '{1}'", testPlanName, testProjectName); return plan; }
public static void GetTestSuiteFromTestPlan(TLTestSuiteCmdletBase cmdlet, TestPlan[] testPlans) { string testPlanNameNow = string.Empty; try { foreach (TestPlan testPlan in testPlans) { testPlanNameNow = testPlan.name; cmdlet.WriteVerbose( cmdlet, "getting suites from the test plan '" + testPlanNameNow + "'."); System.Collections.Generic.List<TestSuite> list = TLAddinData.CurrentTestLinkConnection.GetTestSuitesForTestPlan(testPlan.id); cmdlet.WriteVerbose(cmdlet, "There have been found " + list.Count.ToString() + " test suites."); foreach (TestSuite testSuiteFound in list) { TLAddinData.CurrentTestSuite = testSuiteFound; } cmdlet.WriteObject(cmdlet, list); } } catch (Exception eTestPlan) { cmdlet.WriteError( cmdlet, "Failed to get suites from the test plan '" + testPlanNameNow + "'. " + eTestPlan.Message, "FailedToGetSuites", ErrorCategory.InvalidResult, true); } }
// public static void GetTestCaseFromTestPlan(TLSCmdletBase cmdlet, TestPlan[] testPlans, string[] testCaseNames) { foreach (TestPlan testPlan in testPlans) { System.Collections.Generic.List<TestCaseFromTestPlan> testCases = TLAddinData.CurrentTestLinkConnection.GetTestCasesForTestPlan(testPlan.id); if (null != testCaseNames && 0 < testCaseNames.Length) { foreach (TestCaseFromTestPlan testCase in testCases) { cmdlet.WriteObject(cmdlet, testCase); } } else { cmdlet.WriteObject(cmdlet, testCases); } } }