示例#1
0
        private static void FillRelevantDataForStepParams(QC.QCTSTest newTSTest, QCTestCaseStep tSLinkedTestCaseStep)
        {
            string          description = StripHTML(tSLinkedTestCaseStep.Description).Replace("\n", "");
            MatchCollection mc          = Regex.Matches(description, "\\w*\\s*=\\s*\\w*");

            foreach (Match m in mc)
            {
                string[]             currentParam = m.ToString().Split('=');
                string               paramName    = currentParam[0].Trim(' ');
                string               paramValue   = currentParam[1].Trim(' ');
                QC.QCTSTestParameter newtsVar     = new QC.QCTSTestParameter();
                if (paramName != null)
                {
                    newtsVar.Name = paramName;
                }
                if (paramValue != null)
                {
                    newtsVar.Value = paramValue;
                }
                newTSTest.Parameters.Add(newtsVar);
            }
        }
示例#2
0
        public QC.QCTSTest ImportTSTest(QCTestInstance testInstance)
        {
            QC.QCTSTest newTSTest = new QC.QCTSTest();
            QCTestCase  testCase  = QCRestAPIConnect.GetTestCases(new List <string>()
            {
                testInstance.TestId
            })[0];
            string linkedTest = CheckLinkedTSTestName(testCase);

            if (testInstance != null)
            {
                //Get the TC general details
                if (linkedTest != null)
                {
                    //Linked TC
                    string[] linkTest = linkedTest.Split(';');
                    newTSTest.TestID       = testInstance.Id;
                    newTSTest.TestName     = linkTest[0];
                    newTSTest.LinkedTestID = linkTest[1];
                }
                else
                {
                    //Regular TC
                    newTSTest.TestID       = testInstance.Id;
                    newTSTest.TestName     = testInstance.Name ?? testCase.Name;
                    newTSTest.LinkedTestID = testInstance.TestId;
                }
            }

            //Get the TC design steps
            QCTestCaseStepsColl TSTestSteps = GetListTSTestSteps(testCase);

            foreach (QCTestCaseStep testcaseStep in TSTestSteps)
            {
                QC.QCTSTestStep newtsStep = new QC.QCTSTestStep();
                newtsStep.StepID      = testcaseStep.Id.ToString();
                newtsStep.StepName    = testcaseStep.Name;
                newtsStep.Description = testcaseStep.Description;
                newtsStep.Expected    = testcaseStep.ElementsField["expected"].ToString();
                newTSTest.Steps.Add(newtsStep);
            }

            //Get the TC parameters and their selected value
            if (linkedTest != null)
            {
                if (linkedTest.Split(';')[0] != testCase.Name)
                {
                    if (newTSTest.Description == null)
                    {
                        newTSTest.Description = string.Empty;
                    }
                    newTSTest.Description = testCase.Name.ToString() + System.Environment.NewLine + newTSTest.Description;
                }

                //Linked TC
                QCTestCaseStep TSLinkedTestCaseStep = GetListTSTestVars(testCase);
                if (TSLinkedTestCaseStep != null)
                {
                    FillRelevantDataForStepParams(newTSTest, TSLinkedTestCaseStep);
                }
            }
            else
            {
                ////Regular TC
                QCTestCaseStepsColl TSLinkedTestCaseSteps = QCRestAPIConnect.GetTestCaseSteps(testCase.Id);
                foreach (QCTestCaseStep step in TSLinkedTestCaseSteps)
                {
                    FillRelevantDataForStepParams(newTSTest, step);
                }
            }

            //Get the TC execution history
            try
            {
                QCRunColl TSTestRuns = GetListTSTestRuns(testCase);

                foreach (QCRun run in TSTestRuns)
                {
                    QC.QCTSTestRun newtsRun = new QC.QCTSTestRun();
                    newtsRun.RunID         = run.Id;
                    newtsRun.RunName       = run.Name;
                    newtsRun.Status        = run.Status;
                    newtsRun.ExecutionDate = (run.ElementsField["execution-date"]).ToString();
                    newtsRun.ExecutionTime = (run.ElementsField["execution-time"]).ToString();
                    newtsRun.Tester        = (run.Owner).ToString();
                    newTSTest.Runs.Add(newtsRun);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to pull QC test case RUN info", ex);
                newTSTest.Runs = new List <QC.QCTSTestRun>();
            }

            return(newTSTest);
        }