/// <summary> /// gather all the necessary information prior to /// reporting the results to testlink. /// </summary> /// <param name="result"></param> /// <param name="tlfa"></param> private void reportResult(TestResult result, Meyn.TestLink.TestLinkFixtureAttribute tlfa) { if (!adaptor.UpdateConnectionData(GetConnectionData(tlfa))) { log.Error("Connection error!"); return; } if (!adaptor.UpdateProjectData(tlfa.ProjectName, tlfa.TestPlan, tlfa.PlatformName, tlfa.Buildname)) { log.Error("Error setting project data"); } try { string TestName = result.Name; string MethodName = result.Test.MethodName; if (!TestName.Equals(MethodName)) { /* In case of parameterized tests, result.Name only contains the name of the parameter. So add the name of the actual test (=methodname) also */ TestName = MethodName + "." + TestName; } string TestDescription = result.Description; if (TestDescription == null) { TestDescription = ""; } if (adaptor.ConnectionValid == false) { log.WarnFormat(string.Format("Failed to export tesult for testcase {0}", result.Name)); return; } try { log.Error(string.Format("Exporting result for testcase {0}", result.Name)); sendResultToTestlink(result, tlfa, TestName); } catch (TestLinkException tlex) { log.Error(string.Format("Failed to export testcase '{0}'. {1}", TestName, tlex.Message)); } } catch (TestLinkException tlex) { log.Error(tlex.Message, tlex); } catch (Exception ex) { log.Error(ex.Message, ex); } }
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 GetTestSuiteFromTestSuite(TLTestSuiteCmdletBase cmdlet, Meyn.TestLink.TestSuite[] testSuites) { string testSuiteNameNow = string.Empty; try { foreach (Meyn.TestLink.TestSuite testSuite in testSuites) { testSuiteNameNow = testSuite.name; cmdlet.WriteVerbose( cmdlet, "getting suites from the test suite '" + testSuiteNameNow + "'."); System.Collections.Generic.List<Meyn.TestLink.TestSuite> list = TLAddinData.CurrentTestLinkConnection.GetTestSuitesForTestSuite(testSuite.id); cmdlet.WriteVerbose(cmdlet, "There have been found " + list.Count.ToString() + " test suites."); foreach (Meyn.TestLink.TestSuite testSuiteFound in list) { TLAddinData.CurrentTestSuite = testSuiteFound; } cmdlet.WriteObject(cmdlet, list); } } catch (Exception eTestSuite) { cmdlet.WriteError( cmdlet, "Failed to get suites from the test suite '" + testSuiteNameNow + "'. " + eTestSuite.Message, "FailedToGetSuites", ErrorCategory.InvalidResult, true); } }
// public static void GetTestCaseFromTestPlan(TLSCmdletBase cmdlet, Meyn.TestLink.TestPlan[] testPlans, string[] testCaseNames) { foreach (Meyn.TestLink.TestPlan testPlan in testPlans) { System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestPlan> testCases = TLAddinData.CurrentTestLinkConnection.GetTestCasesForTestPlan(testPlan.id); if (null != testCaseNames && 0 < testCaseNames.Length) { foreach (Meyn.TestLink.TestCaseFromTestPlan testCase in testCases) { cmdlet.WriteObject(cmdlet, testCase); } } else { cmdlet.WriteObject(cmdlet, testCases); } } }
public static void GetTestCaseFromProject(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects, string[] testCaseNames) { foreach (Meyn.TestLink.TestProject project in testProjects) { System.Collections.Generic.List<Meyn.TestLink.TestPlan> testPlans = TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans(project.id); TLHelper.GetTestCaseFromTestPlan(cmdlet, testPlans.ToArray(), testCaseNames); System.Collections.Generic.List<Meyn.TestLink.TestSuite> firstLevelTestSuites = TLAddinData.CurrentTestLinkConnection.GetFirstLevelTestSuitesForTestProject(project.id); TLHelper.GetTestCaseFromTestSuite(cmdlet, firstLevelTestSuites.ToArray(), testCaseNames, true); // foreach (Meyn.TestLink.TestSuite suite in firstLevelTestSuites) { // // // } } }
// public static void GetTestSubSuite(TLSCmdletBase cmdlet, string name) // { // throw new NotImplementedException(); // } // public static void OpenTestSubSuite(TLSCmdletBase cmdlet, string name) // { // throw new NotImplementedException(); // } public static void AddTestCase( TLSCmdletBase cmdlet, string name, string authorLogin, int suiteId, int testProjectId, string summary, string[] keyword, int order, bool checkDuplicatedName, Meyn.TestLink.ActionOnDuplicatedName actionDuplicatedName, int executionType, int importance) { string keywords = string.Empty; if (null != keyword && 0 < keyword.Length) { foreach (string singleKeyword in keyword) { keywords += singleKeyword; } } if (null == TLAddinData.CurrentTestProject) { // Console.WriteLine("!!!"); // } if (null == actionDuplicatedName) { actionDuplicatedName = ActionOnDuplicatedName.CreateNewVersion; } TLAddinData.CurrentTestLinkConnection.CreateTestCase( authorLogin, suiteId, name, testProjectId, summary, keywords, order, checkDuplicatedName, actionDuplicatedName, executionType, importance); // //TLAddinData.CurrentTestLinkConnection.ReportTCResult }
public static void GetTestPlan(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects, string[] testPlanNames) { string testPlanNameNow = string.Empty; try { // if (null == testProjects || 0 == testProjects.Length) { // if (null != TLAddinData.CurrentTestProject) { // testProjects = new Meyn.TestLink.TestProject[1]; // testProjects[0] = TLAddinData.CurrentTestProject; // } // } if (null == testProjects || 0 == testProjects.Length) { //cmdlet.WriteObject(cmdlet, null); // ?? return; } foreach (Meyn.TestLink.TestProject testProject in testProjects) { foreach (string name in testPlanNames) { testPlanNameNow = name; cmdlet.WriteVerbose( cmdlet, "Trying to get test plan '" + testPlanNameNow + "' from the project '" + testProject.name + "'."); TestPlan testPlan = TLAddinData.CurrentTestLinkConnection.getTestPlanByName( testProject.name, testPlanNameNow); if (null != testPlan) { TLAddinData.CurrentTestPlan = testPlan; cmdlet.WriteObject(cmdlet, testPlan); } } } } catch (Exception eGetTestPlan) { cmdlet.WriteError( cmdlet, "Couldn't get test plan '" + testPlanNameNow + "'. " + eGetTestPlan.Message, "" + "CouldNotCreateTestPlan", ErrorCategory.InvalidResult, true); } }
public static void GetTestPlans(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects) { try { for (int i = 0; i < testProjects.Length; i++) { if (null == testProjects[i]) { if (null != TLAddinData.CurrentTestProject) { testProjects[i] = TLAddinData.CurrentTestProject; } else { cmdlet.WriteError( cmdlet, "You must specify a test project.", "NoTestProjectSpecified", ErrorCategory.InvalidArgument, true); } } System.Collections.Generic.List<TestPlan> listTestPlans = TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans( testProjects[i].id); foreach (TestPlan tplan in listTestPlans) { TLAddinData.CurrentTestPlan = tplan; } cmdlet.WriteObject(cmdlet, listTestPlans); } } catch (Exception eGetTestPlans) { cmdlet.WriteError( cmdlet, "Couldn't get test plans. " + eGetTestPlans.Message, "" + "CouldNotCreateTestPlan", ErrorCategory.InvalidResult, true); } }