Beispiel #1
0
        /// <summary>
        /// Export Activities Group details to QC, can be used for creating new matching QC Test Case or updating an existing one
        /// </summary>
        /// <param name="activitiesGroup">Activities Group to Export</param>
        /// <param name="mappedTest">The QC Test Case which mapped to the Activities Group (in case exist) and needs to be updated</param>
        /// <param name="uploadPath">Upload path in QC Test Plan</param>
        /// <param name="result">Export error result</param>
        /// <returns></returns>
        public static bool ExportActivitiesGroupToQC(ActivitiesGroup activitiesGroup, Test mappedTest, string uploadPath, ObservableList <ExternalItemFieldBase> testCaseFields, ref string result)
        {
            Test test;

            try
            {
                if (mappedTest == null)
                {
                    //##create new Test Case in QC
                    TestFactory TestF = (TestFactory)mTDConn.TestFactory;
                    test      = (Test)TestF.AddItem(System.DBNull.Value);
                    test.Type = "MANUAL";

                    //set the upload path
                    TreeManager  treeM            = (TreeManager)mTDConn.TreeManager;
                    ISysTreeNode testParentFolder = (ISysTreeNode)treeM.get_NodeByPath(uploadPath);
                    test["TS_SUBJECT"] = testParentFolder.NodeID;
                }
                else
                {
                    //##update existing test case
                    test = ImportFromQC.GetQCTest(activitiesGroup.ExternalID);

                    //delete the un-needed steps
                    DesignStepFactory stepF = test.DesignStepFactory;
                    List stepsList          = stepF.NewList("");
                    foreach (DesignStep step in stepsList)
                    {
                        if (activitiesGroup.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity.ExternalID == step.ID.ToString()).FirstOrDefault() == null)
                        {
                            stepF.RemoveItem(step.ID);
                        }
                    }

                    //delete the existing parameters
                    StepParams testParams = test.Params;
                    if (testParams.Count > 0)
                    {
                        for (int indx = 0; indx < testParams.Count; indx++)
                        {
                            testParams.DeleteParam(testParams.ParamName[indx]);
                            testParams.Save();
                        }
                    }
                }

                //set item fields
                foreach (ExternalItemFieldBase field in testCaseFields)
                {
                    if (field.ToUpdate || field.Mandatory)
                    {
                        if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA")
                        {
                            test[field.ID] = field.SelectedValue;
                        }
                        else
                        {
                            try { test[field.ID] = "NA"; }
                            catch { }
                        }
                    }
                }

                //post the test
                test.Name = activitiesGroup.Name;
                test.Post();
                activitiesGroup.ExternalID  = test.ID.ToString();
                activitiesGroup.ExternalID2 = test.ID.ToString();

                //Add/update all test steps + Parameters
                foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers)
                {
                    ExportActivityAsTestStep(test, (Activity)actIdent.IdentifiedActivity);
                }

                return(true);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the Activities Group to QC/ALM", ex);
                return(false);
            }
        }
Beispiel #2
0
        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"], @"<[^>]+>|&nbsp;", "").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;
            }
        }