Пример #1
0
        /// <summary>
        /// summerizes test steps after test has run
        /// </summary>
        /// <param name="test"></param>
        /// <returns>a string containing descriptions of step states and messags</returns>
        string GetTestStepsDescFromQc(ITSTest test)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                //get runs for the test
                RunFactory rfactory = test.RunFactory;
                List       runs     = rfactory.NewList("");
                if (runs.Count == 0)
                {
                    return("");
                }

                //get steps from run
                StepFactory stepFact = runs[runs.Count].StepFactory;
                List        steps    = stepFact.NewList("");
                if (steps.Count == 0)
                {
                    return("");
                }

                //go over steps and format a string
                foreach (IStep step in steps)
                {
                    sb.Append("Step: " + step.Name);

                    if (!string.IsNullOrWhiteSpace(step.Status))
                    {
                        sb.Append(", Status: " + step.Status);
                    }

                    string desc = step["ST_DESCRIPTION"] as string;
                    if (!string.IsNullOrEmpty(desc))
                    {
                        desc = "\n\t" + desc.Trim().Replace("\n", "\t").Replace("\r", "");
                        if (!string.IsNullOrWhiteSpace(desc))
                        {
                            sb.AppendLine(desc);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sb.AppendLine("Exception while reading step data: " + ex.Message);
            }

            return(sb.ToString().TrimEnd());
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public bool Add(string TestSetFolderPath, string testsetName, string testName, string runName, string status, string _attachmentPath, string _attachmentName, string installogPath, string installlogName, List <RunSteps> steps)
        {
            TestSetFactory     TestSetFact;
            TestSetTreeManager tsTreeMgr;
            TestSetFolder      tSetFolder;
            List     lst;
            TDFilter TestFilter;
            Run      therun;

            tsTreeMgr  = tdconn.TestSetTreeManager as TestSetTreeManager;
            tSetFolder = tsTreeMgr.Root as TestSetFolder;

            tSetFolder = tsTreeMgr.get_NodeByPath(TestSetFolderPath) as TestSetFolder;



            TestSetFact            = tSetFolder.TestSetFactory as TestSetFactory;
            TestFilter             = TestSetFact.Filter as TDFilter;
            TestFilter["CY_CYCLE"] = "'" + testsetName + "'";

            lst = TestSetFact.NewList(TestFilter.Text); // list index from 1

            TestSet ts = lst[1] as TestSet;


            TestFilter.Clear();



            TSTestFactory tsF = ts.TSTestFactory as TSTestFactory;

            TestFilter            = tsF.Filter as TDFilter;
            TestFilter["TS_NAME"] = "'" + testName + "'";

            TSTest TestInstance = tsF.NewList(TestFilter.Text)[1] as TSTest;


            RunFactory rf      = TestInstance.RunFactory as RunFactory;
            List       runlist = rf.NewList("");

            //update run is run exist
            for (int index = 1; index <= runlist.Count; index++)
            {
                therun = runlist[index] as Run;
                if (therun.Name == runName)
                {
                    foreach (RunSteps runstep in steps)
                    {
                        runstep.Add(therun);
                    }
                    return(true);
                }
            }



            therun        = rf.AddItem(runName) as Run;
            therun.Status = status;
            //therun["RN_DURATION"] = duration;
            therun.Post(); //add run
            if (File.Exists(_attachmentPath + "\\" + _attachmentName))
            {
                AttachmentFactory attachFact = therun.Attachments as AttachmentFactory;
                Attachment        attachfile;
                IExtendedStorage  extStor;
                attachfile          = attachFact.AddItem(_attachmentName) as Attachment;
                attachfile.AutoPost = true;
                extStor             = attachFact.AttachmentStorage as IExtendedStorage;
                extStor.ClientPath  = _attachmentPath;
                extStor.Save(_attachmentName, true);
                attachfile.Post();
            }

            if (File.Exists(installogPath + "\\" + installlogName))
            {
                AttachmentFactory attachFact = therun.Attachments as AttachmentFactory;
                Attachment        attachfile;
                IExtendedStorage  extStor;
                attachfile = attachFact.AddItem(installlogName) as Attachment;

                attachfile.AutoPost = true;

                extStor            = attachFact.AttachmentStorage as IExtendedStorage;
                extStor.ClientPath = installogPath;
                extStor.Save(installlogName, true);
                attachfile.Post();
            }

            therun.AutoPost = true;
            int count = 0;

            foreach (RunSteps runstep in steps)
            {
                ++count;
                Console.WriteLine("Uploading step " + count + ":" + runstep.StepName);
                runstep.Add(therun);
            }

            return(true);
        }