private void DisplayListOFTestPlan(TDAPIOLELib.List testList, TestFactory testFactory) { MultipleTestSelection mts = new MultipleTestSelection(); MultipleTestSelection.TestList = (TDAPIOLELib.List)testList; mts.LoadTestPLans(testFactory); mts.ShowDialog(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { TDConnection tdConn = new TDConnection(); tdConn.InitConnectionEx(qcUrl.Text); tdConn.ConnectProjectEx(qcDomain.Text, qcProject.Text, qcLogin.Text, qcPassword.Password); //MessageBox.Show((string)qcUrl.Text); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)qcProject.Text); //MessageBox.Show((string)qcLogin.Text); //MessageBox.Show((string)qcPassword.Password); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)testFolder.Text); //MessageBox.Show((string)testSet.Text); //RunFactory runFactory = (RunFactory)test.RunFactory;// //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; //string testSet = "BNF SDKv4 Server and Update"; TestSetFactory tsFactory = (TestSetFactory)tdConn.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)tdConn.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder.Text); TDAPIOLELib.List tsList = (TDAPIOLELib.List)tsFolder.FindTestSets((string)testSet.Text, false, null); //TDAPIOLELib.List tsTestList = tsFactory.NewList(""); //List tsList = tsFolder.FindTestSets(testSet, false, "status=No Run"); //Feature\Multum\Black Box\Monthly Testing\SDK v4 foreach (TestSet testset in tsList) { Console.WriteLine("Test Set Folder Path: {0}", testFolder); Console.WriteLine("Test Set: {0}", testset.Name); TestSetFolder tsfolder = (TestSetFolder)testset.TestSetFolder; //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; TSTestFactory tsTestFactory = (TSTestFactory)testset.TSTestFactory; TDAPIOLELib.List tsTestList = tsTestFactory.NewList(""); //} foreach (TSTest tsTest in tsTestList)//no such interface supported { Console.WriteLine("Test Set: {0}", tsTest.Name); //Console.ReadLine(); string status = (string)tsTest.Status; Console.WriteLine("STATUS {0}", status); //Console.WriteLine("PARAMS {0}",tsTest.Params); Console.WriteLine("PARAMS {0}", tsTest.History); TDAPIOLELib.Run lastRun = (TDAPIOLELib.Run)tsTest.LastRun; // don't update test if it may have been modified by someone else if (lastRun == null) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; TDAPIOLELib.List runs = runFactory.NewList(""); Console.WriteLine("test runs: {0}", runs.Count); String date = DateTime.Now.ToString("MM-dd_hh-mm-ss"); TDAPIOLELib.Run run = (TDAPIOLELib.Run)runFactory.AddItem("Run_" + date); //Run_5-23_14-49-52 var oRunInstance = (RunFactory)tsTest.RunFactory; //var oRun = (Run)oRunInstance.AddItem("Performance Test"); //run.Status = "Passed"; //run.Post(); //run.Refresh(); var oTest = (Test)tsTest.Test; var tsDesignStepList = oTest.DesignStepFactory.NewList(""); var oStepFactory = (StepFactory)run.StepFactory; foreach (DesignStep oDesignStep in tsDesignStepList) { var oStep = (Step)oStepFactory.AddItem(oDesignStep.StepName); //oStep.Status = "Passed"; //oStep.Post(); } } } } tdConn.DisconnectProject(); tdConn.Disconnect(); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
public void ParseDataSet(params object[] parameters) { lstTestPlanSteps = new List <string[]>(); lstStrEvidenceID = new List <string>(); try { string strQCURL = (string)parameters[0]; string strTargetFolderPath = (string)parameters[1]; string strproject = (string)parameters[2]; string strdomain = (string)parameters[3]; string strpass = (string)parameters[4]; string strTestPlanFileName = Path.GetFileNameWithoutExtension((string)parameters[5]); bool bIsCandidateEvidence = false; string strscreenprint = string.Empty; TDConnection qctd = new TDConnection(); Test tst; qctd.InitConnectionEx(strQCURL); qctd.ConnectProjectEx(strdomain, strproject, Environment.UserName, strpass); if (qctd.Connected) { TestFactory testFactory = (TestFactory)qctd.TestFactory; TDFilter testFilter = testFactory.Filter; TDAPIOLELib.List testList; testFilter["TS_NAME"] = "\"" + strTestPlanFileName + "\""; // testFilter["TS_PATH"] = "\"" + strTargetFolderPath + "\""; TDAPIOLELib.List listOfTests = testFilter.NewList(); testList = (TDAPIOLELib.List)testFactory.NewList(testFilter.Text); string strdescription = string.Empty; int itestcount = testList.Count; int stepscount = 0; if (testList.Count == 0) { throw new FileNotFoundException("No test plans Found .Check the testplan name"); } else if (testList.Count > 1) { MessageBox.Show("Multiple Test plans found , Click Ok to view and select the Right Test Plan", "Mutiple Test Plans"); DisplayListOFTestPlan(testList, testFactory); tst = SelectedTest; strTestplanPath = testFactory[tst.ID]["TS_SUBJECT"].Path; } else { tst = testList[1]; } if (tst == null) { throw new Exception("No Test plans selected "); } strTestPlanName = tst.Name; // string noHTML = Regex.Replace(tst["TS_DESCRIPTION"], @"<[^>]+>| ", "").Trim(); // noHTML = WebUtility.HtmlDecode(noHTML); string noHTML = RemoveHTML(tst["TS_DESCRIPTION"]); // Match m = Regex.Match(noHTML, "(?s)[Pp]rerequisites.*[Cc]hange [Cc]ontrol"); Match m = Regex.Match(noHTML, "(?s)[Pp]rerequisites.*"); strPrerequisites = m.Value; DesignStepFactory dsf = tst.DesignStepFactory; TDAPIOLELib.List dslflist = dsf.NewList(""); stepscount = dslflist.Count; foreach (DesignStep ds in dslflist) { arrStepData = new string[3]; arrStepData[0] = ds.StepName; arrStepData[1] = RemoveHTML(ds.StepDescription); arrStepData[2] = RemoveHTML(ds.StepExpectedResult); lstTestPlanSteps.Add(arrStepData); bIsCandidateEvidence = false; strscreenprint = (string)ds["DS_USER_01"]; if (!string.IsNullOrEmpty(strscreenprint)) { if (string.Compare(strscreenprint.ToLower(), "none") != 0) { foreach (char ch in strscreenprint) { if ((int)ch >= 33 && (int)ch <= 126) { bIsCandidateEvidence = true; break; } } if (bIsCandidateEvidence) { lstStrEvidenceID.Add(ds.StepName); } } } } } } catch (Exception ex) { throw ex; } }