Exemple #1
0
        public bool ExportActivitiesGroupToALM(ActivitiesGroup activitiesGroup, QtestTest mappedTest, string parentObjectId, ObservableList <ExternalItemFieldBase> testCaseFields, ref string result)
        {
            ConnectALMServer();
            testcaseApi = new QTestApi.TestcaseApi(connObj.Configuration);

            try
            {
                if (mappedTest == null) // Create new test case
                {
                    QTestApiModel.TestCaseWithCustomFieldResource testCase = new QTestApiModel.TestCaseWithCustomFieldResource(null, null, null, new List <QTestApiModel.PropertyResource>());
                    testCase.Description = activitiesGroup.Description;
                    testCase.Name        = activitiesGroup.Name;
                    testCase             = testcaseApi.CreateTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase);
                    foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers)
                    {
                        QTestApiModel.TestStepResource stepResource = new QTestApiModel.TestStepResource(null, null,
                                                                                                         ((Activity)actIdent.IdentifiedActivity).Description == null ? string.Empty : ((Activity)actIdent.IdentifiedActivity).Description,
                                                                                                         ((Activity)actIdent.IdentifiedActivity).Expected == null ? string.Empty : ((Activity)actIdent.IdentifiedActivity).Expected);
                        stepResource.PlainValueText = ((Activity)actIdent.IdentifiedActivity).ActivityName;
                        stepResource = testcaseApi.AddTestStep((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id, stepResource);
                        ((Activity)actIdent.IdentifiedActivity).ExternalID  = stepResource.Id.ToString();
                        ((Activity)actIdent.IdentifiedActivity).ExternalID2 = stepResource.Id.ToString();
                    }
                    activitiesGroup.ExternalID  = testCase.Id.ToString();
                    activitiesGroup.ExternalID2 = testCase.Id.ToString();
                }
                else
                {
                    // update existing test case
                }

                return(true);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + " to qTest", ex);
                return(false);
            }
        }
Exemple #2
0
        public bool ExportBusinessFlowToALM(BusinessFlow businessFlow, QtestTestSuite mappedTestSuite, string parentObjectId, ObservableList <ExternalItemFieldBase> testSetFields, ref string result)
        {
            ConnectALMServer();
            testrunApi  = new QTestApi.TestrunApi(connObj.Configuration);
            testcaseApi = new QTestApi.TestcaseApi(connObj.Configuration);
            QTestApi.TestsuiteApi testsuiteApi = new QTestApi.TestsuiteApi(connObj.Configuration);

            ObservableList <ActivitiesGroup> existingActivitiesGroups = new ObservableList <ActivitiesGroup>();

            try
            {
                QTestApiModel.TestSuiteWithCustomFieldResource testSuite = null;
                if (mappedTestSuite == null)
                {
                    testSuite = new QTestApiModel.TestSuiteWithCustomFieldResource(null, null, null, null,
                                                                                   businessFlow.Name,
                                                                                   new List <QTestApiModel.PropertyResource>());
                    testSuite = testsuiteApi.CreateTestSuite((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testSuite, (long)Convert.ToInt32(parentObjectId), "test-cycle");

                    foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups)
                    {
                        QTestApiModel.TestRunWithCustomFieldResource testRun = new QTestApiModel.TestRunWithCustomFieldResource(null, null, null, null,
                                                                                                                                ag.Name,
                                                                                                                                new List <QTestApiModel.PropertyResource>(),
                                                                                                                                testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(ag.ExternalID)));
                        testrunApi.Create((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testRun, testSuite.Id, "test-suite");
                    }
                }
                else
                {
                    //update test-suite
                    testSuite = new QTestApiModel.TestSuiteWithCustomFieldResource(null, null, null, null,
                                                                                   businessFlow.Name,
                                                                                   new List <QTestApiModel.PropertyResource>());
                    testSuite = testsuiteApi.UpdateTestSuite((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(mappedTestSuite.ID), testSuite);


                    //##update existing TestSuite -> TestRun
                    foreach (QtestTest test in mappedTestSuite.Tests)
                    {
                        QTestApiModel.TestRunWithCustomFieldResource  testRun  = testrunApi.Get((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(test.Runs[0].RunID), "descendents");
                        QTestApiModel.TestCaseWithCustomFieldResource testCase = testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testRun.TestCase.Id);

                        ActivitiesGroup ag = businessFlow.ActivitiesGroups.Where(x => (x.ExternalID == test.TestID.ToString())).FirstOrDefault();
                        if (ag != null)
                        {
                            foreach (ActivityIdentifiers actIdent in ag.ActivitiesIdentifiers)
                            {
                                if ((actIdent.IdentifiedActivity.ExternalID == null) && (actIdent.IdentifiedActivity.ExternalID2 == null))
                                {
                                    QTestApiModel.TestCaseWithCustomFieldResource newTestCase = new QTestApiModel.TestCaseWithCustomFieldResource(null, null, null, new List <QTestApiModel.PropertyResource>());
                                    newTestCase.Description = actIdent.ActivityDescription;
                                    newTestCase.Name        = actIdent.ActivityName;
                                    testcaseApi.CreateTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), newTestCase);
                                    string stepNameWithDesc = ((Activity)actIdent.IdentifiedActivity).ActivityName + "=>" + ((Activity)actIdent.IdentifiedActivity).Description;
                                    QTestApiModel.TestStepResource stepResource = new QTestApiModel.TestStepResource(null, null,
                                                                                                                     stepNameWithDesc,
                                                                                                                     ((Activity)actIdent.IdentifiedActivity).Expected == null ? string.Empty : ((Activity)actIdent.IdentifiedActivity).Expected);
                                    stepResource.PlainValueText = ((Activity)actIdent.IdentifiedActivity).ActivityName;
                                    testcaseApi.AddTestStep((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), newTestCase.Id, stepResource);

                                    stepResource = new QTestApiModel.TestStepResource(null, null, string.Empty, string.Empty,
                                                                                      null, null, null, null, null, newTestCase.Id);
                                    stepResource = testcaseApi.AddTestStep((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id, stepResource);

                                    actIdent.IdentifiedActivity.ExternalID  = newTestCase.Id.ToString();
                                    actIdent.IdentifiedActivity.ExternalID2 = stepResource.Id.ToString();
                                }
                            }
                        }
                    }
                }

                businessFlow.ExternalID = testSuite != null?testSuite.Id.ToString() : string.Empty;

                WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(businessFlow);
                return(true);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " to qTest", ex);
                return(false);
            }
        }
Exemple #3
0
        public bool ExportActivitiesGroupToALM(ActivitiesGroup activitiesGroup, QtestTest mappedTest, string parentObjectId, ObservableList <ExternalItemFieldBase> testCaseFields, ref string result)
        {
            ConnectALMServer();
            testcaseApi = new QTestApi.TestcaseApi(connObj.Configuration);

            try
            {
                if (mappedTest == null) // Create new test case
                {
                    QTestApiModel.TestCaseWithCustomFieldResource testCase = new QTestApiModel.TestCaseWithCustomFieldResource(null, null, null, new List <QTestApiModel.PropertyResource>());
                    testCase.Description = activitiesGroup.Description;
                    testCase.Name        = activitiesGroup.Name;
                    testCase.ParentId    = (long)Convert.ToInt32(parentObjectId);
                    //create testCase
                    testCase = testcaseApi.CreateTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase);
                    //add testSteps
                    foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers)
                    {
                        string stepNameWithDesc = ((Activity)actIdent.IdentifiedActivity).ActivityName + "=>" + ((Activity)actIdent.IdentifiedActivity).Description;
                        QTestApiModel.TestStepResource stepResource = new QTestApiModel.TestStepResource(null, null,
                                                                                                         stepNameWithDesc,
                                                                                                         ((Activity)actIdent.IdentifiedActivity).Expected == null ? string.Empty : ((Activity)actIdent.IdentifiedActivity).Expected);
                        stepResource.PlainValueText = ((Activity)actIdent.IdentifiedActivity).ActivityName;
                        stepResource = testcaseApi.AddTestStep((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id, stepResource);
                        ((Activity)actIdent.IdentifiedActivity).ExternalID  = stepResource.Id.ToString();
                        ((Activity)actIdent.IdentifiedActivity).ExternalID2 = stepResource.Id.ToString();
                    }

                    //approve testCase - it needs to be called each time whenever testCase is updated
                    testcaseApi.ApproveTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id);

                    activitiesGroup.ExternalID  = testCase.Id.ToString();
                    activitiesGroup.ExternalID2 = testCase.Id.ToString();
                }
                else
                {
                    // update existing test case
                    QTestApiModel.TestCaseWithCustomFieldResource testCase = testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(mappedTest.TestID));;

                    //update testCase
                    testCase.Description = activitiesGroup.Description;
                    testCase.Name        = activitiesGroup.Name;
                    testCase             = testcaseApi.UpdateTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id, testCase);

                    //update steps
                    int counter = 0;
                    foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers)
                    {
                        //get testCase each time because update step changes the ids of the steps
                        testCase = testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(mappedTest.TestID));

                        string stepNameWithDesc = ((Activity)actIdent.IdentifiedActivity).ActivityName + "=>" + ((Activity)actIdent.IdentifiedActivity).Description;
                        QTestApiModel.TestStepResource stepResource = new QTestApiModel.TestStepResource(null, null,
                                                                                                         stepNameWithDesc,
                                                                                                         ((Activity)actIdent.IdentifiedActivity).Expected == null ? string.Empty : ((Activity)actIdent.IdentifiedActivity).Expected);
                        stepResource.PlainValueText = ((Activity)actIdent.IdentifiedActivity).ActivityName;

                        stepResource = testcaseApi.UpdateTestStep((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id, testCase.TestSteps[counter].Id, stepResource);
                        ((Activity)actIdent.IdentifiedActivity).ExternalID  = stepResource.Id.ToString();
                        ((Activity)actIdent.IdentifiedActivity).ExternalID2 = stepResource.Id.ToString();

                        counter++;
                    }

                    //approve testCase - it needs to be called each time whenever testCase is updated
                    testcaseApi.ApproveTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testCase.Id);
                }

                return(true);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export the " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + " to qTest", ex);
                return(false);
            }
        }