public abstract bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null);
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { result = string.Empty; if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID)) { result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID"; return(false); } try { //get the BF matching test set ConnectALMServer(); testcaseApi = new QTestApi.TestcaseApi(connObj.Configuration); testrunApi = new QTestApi.TestrunApi(connObj.Configuration); QTestApi.TestlogApi testlogApi = new QTestApi.TestlogApi(connObj.Configuration); QTestApi.AttachmentApi attachmentApi = new QTestApi.AttachmentApi(connObj.Configuration); QtestTestSuite testSuite = GetQtestTestSuite(bizFlow.ExternalID); if (testSuite != null) { //get all BF Activities groups ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups; if (activGroups.Count > 0) { foreach (ActivitiesGroup activGroup in activGroups) { if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) || (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) || publishToALMConfig.FilterStatus == FilterByStatus.All) { QtestTest tsTest = null; //go by TC ID = TC Instance ID tsTest = testSuite.Tests.Where(x => x.TestID == activGroup.ExternalID).FirstOrDefault(); if (tsTest != null) { //get activities in group List <Activity> activities = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList(); string TestCaseName = PathHelper.CleanInValidPathChars(tsTest.TestName); if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty)) { String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss"); publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp; } if (tsTest.Runs[0] != null) { List <QTestApiModel.StatusResource> statuses = testrunApi.GetStatusValuable((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey)); List <QTestApiModel.StatusResource> stepsStatuses = new List <QTestApiModel.StatusResource>(); QTestApiModel.StatusResource testCaseStatus; QTestApiModel.TestRunWithCustomFieldResource testRun = testrunApi.Get((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), (long)Convert.ToInt32(tsTest.Runs[0].RunID), "descendents"); List <QTestApiModel.TestStepLogResource> testStepLogs = new List <QTestApiModel.TestStepLogResource>(); QTestApiModel.TestCaseWithCustomFieldResource testCase = testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), testRun.TestCase.Id); int testStepsCount = 0; foreach (QTestApiModel.TestStepResource step in testCase.TestSteps) { if (step.CalledTestCaseId != null) { QTestApiModel.TestCaseWithCustomFieldResource calledTestCase = testcaseApi.GetTestCase((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), step.CalledTestCaseId); foreach (QTestApiModel.TestStepResource nestedStep in calledTestCase.TestSteps) { Activity matchingActivity = activities.Where(x => x.ExternalID == nestedStep.Id.ToString()).FirstOrDefault(); if (matchingActivity != null) { QTestApiModel.TestStepLogResource testStepLog = new QTestApiModel.TestStepLogResource(null, nestedStep.Id); testStepLog.CalledTestCaseId = step.CalledTestCaseId; testStepLog.ParentTestStepId = step.Id; testStepLog.ActualResult = string.Empty; SetTestStepLogStatus(matchingActivity, ref testStepLog, statuses); stepsStatuses.Add(testStepLog.Status); testStepLogs.Add(testStepLog); testStepsCount++; } } } else { Activity matchingActivity = activities.Where(x => x.ExternalID == step.Id.ToString()).FirstOrDefault(); if (matchingActivity != null) { QTestApiModel.TestStepLogResource testStepLog = new QTestApiModel.TestStepLogResource(null, step.Id); testStepLog.ActualResult = string.Empty; SetTestStepLogStatus(matchingActivity, ref testStepLog, statuses); stepsStatuses.Add(testStepLog.Status); testStepLogs.Add(testStepLog); testStepsCount++; } } } //update the TC general status based on the activities status collection. if (stepsStatuses.Where(x => x.Name == "Failed").Count() > 0) { testCaseStatus = statuses.Where(z => z.Name == "Failed").FirstOrDefault(); } else if (stepsStatuses.Where(x => x.Name == "No Run").Count() == testStepsCount || stepsStatuses.Where(x => x.Name == "Not Applicable").Count() == testStepsCount) { testCaseStatus = statuses.Where(z => z.Name == "Unexecuted").FirstOrDefault(); } else if (stepsStatuses.Where(x => x.Name == "Passed").Count() == testStepsCount || (stepsStatuses.Where(x => x.Name == "Passed").Count() + stepsStatuses.Where(x => x.Name == "Unexecuted").Count()) == testStepsCount) { testCaseStatus = statuses.Where(z => z.Name == "Passed").FirstOrDefault(); } else { testCaseStatus = statuses.Where(z => z.Name == "Unexecuted").FirstOrDefault(); } QTestApiModel.ManualTestLogResource automationTestLog = new QTestApiModel.ManualTestLogResource(null, null, DateTime.Parse(bizFlow.StartTimeStamp.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:sszz:00")), DateTime.Parse(bizFlow.EndTimeStamp.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:sszz:00")), null, null, tsTest.TestName + " - execution", null, null, null, null, null, testCaseStatus, null, testStepLogs); QTestApiModel.TestLogResource testLog = testlogApi.SubmitTestLog((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), automationTestLog, (long)Convert.ToInt32(tsTest.Runs[0].RunID)); // Attach ActivityGroup Report if needed if (publishToALMConfig.ToAttachActivitiesGroupReport) { if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) && (System.IO.Directory.Exists(activGroup.TempReportFolder))) { //Creating the Zip file - start string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString(); string zipFileName = targetZipPath + "\\" + TestCaseName + "_GingerHTMLReport.zip"; if (!System.IO.File.Exists(zipFileName)) { ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName); } else { System.IO.File.Delete(zipFileName); ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName); } System.IO.Directory.Delete(activGroup.TempReportFolder, true); // to discuss an issue attachmentApi.Upload((long)Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), "test-logs", testLog.Id, "GingerExecutionHTMLReport.zip", "application/x-zip-compressed", File.ReadAllBytes(zipFileName)); System.IO.File.Delete(zipFileName); } } } } else { //No matching TC was found for the ActivitiesGroup in QC result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in qTest."; } } } } else { //No matching Test Set was found for the BF in QC result = "No matching Test Set was found in qTest."; } } if (result == string.Empty) { result = "Export performed successfully."; return(true); } else { return(false); } } catch (Exception ex) { result = "Unexpected error occurred- " + ex.Message; Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to Qtest", ex); return(false); } }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { ObservableList <ExternalItemFieldBase> runFields = GetALMItemFields(null, true, ALM_Common.DataContracts.ResourceType.TEST_RUN); return(ExportToQCRestAPI.ExportExceutionDetailsToALM(bizFlow, ref result, runFields, exectutedFromAutomateTab, publishToALMConfig)); }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { return(ExportToRQM.Instance.ExportExecutionDetailsToRQM(bizFlow, ref result, exectutedFromAutomateTab, publishToALMConfig)); }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { bool IsExecute = zephyrEntExportManager.ExportExceutionDetailsToALM(bizFlow, ref result, null, exectutedFromAutomateTab, publishToALMConfig); if (!IsExecute) { CreateActivitiesGroupsExecution(bizFlow); } return(zephyrEntExportManager.ExportExceutionDetailsToALM(bizFlow, ref result, null, exectutedFromAutomateTab, publishToALMConfig)); }
public bool ExportBusinessFlowsResultToALM(ObservableList <BusinessFlow> BusinessFlows, ref string result, PublishToALMConfig publishToALMConfig, eALMConnectType almConnectionType, bool exectutedFromAutomateTab = false) { SolutionFolder = WorkSpace.Instance.Solution.Folder.ToUpper(); bool isExportSucc = false; try { foreach (BusinessFlow BizFlow in BusinessFlows) //Here going for each businessFlow { try { if (BizFlow.ExternalID != "0" && !String.IsNullOrEmpty(BizFlow.ExternalID)) { Reporter.ToLog(eLogLevel.DEBUG, "Executing RunSet Action Publish to ALM for " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " " + BizFlow.Name); Reporter.ToStatus(eStatusMsgKey.ExportExecutionDetails, null, BizFlow.Name, "ALM"); if (publishToALMConfig.ToAttachActivitiesGroupReport) { Ginger.Reports.GingerExecutionReport.ExtensionMethods.CreateActivitiesGroupReportsOfBusinessFlow(null, BizFlow);//need to find a way to specify the releveant environment } isExportSucc = ExportExecutionDetailsToALM(BizFlow, ref result, exectutedFromAutomateTab, publishToALMConfig); if (isExportSucc) { BizFlow.PublishStatus = BusinessFlow.ePublishStatus.Published; } else { if ((result == null) || (result == string.Empty)) { result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " - " + BizFlow.Name + " - Error when uploading to ALM." + Environment.NewLine; } BizFlow.PublishStatus = BusinessFlow.ePublishStatus.PublishFailed; } Reporter.HideStatusMessage(); } else { BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished; result = $"{result}{GingerDicser.GetTermResValue(eTermResKey.BusinessFlow)} - {BizFlow.Name} - doesn't have ExternalID, cannot execute publish to ALM RunSet Action{Environment.NewLine}"; Reporter.ToLog(eLogLevel.WARN, BizFlow.Name + " - doesn't have ExternalID, cannot execute publish to ALM RunSet Action"); } } catch (Exception ex) { result = ex.Message; BizFlow.PublishStatus = BusinessFlow.ePublishStatus.NotPublished; Reporter.ToLog(eLogLevel.ERROR, BizFlow.Name + " - Export results to ALM failed due to exception", ex); } } return(isExportSucc); } finally { DisconnectALMServer(); } }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { if (WorkSpace.Instance.BetaFeatures.JiraTestingALM) { switch (ALMCore.DefaultAlmConfig.JiraTestingALM) { case GingerCoreNET.ALMLib.ALMIntegration.eTestingALMType.Xray: return(exportMananger.ExecuteDataToJira(bizFlow, publishToALMConfig, ref result)); case GingerCoreNET.ALMLib.ALMIntegration.eTestingALMType.Zephyr: return(exportMananger.ExportExecutionDetailsToJiraZephyr(bizFlow, publishToALMConfig, ref result)); default: return(exportMananger.ExecuteDataToJira(bizFlow, publishToALMConfig, ref result)); } } else { return(exportMananger.ExecuteDataToJira(bizFlow, publishToALMConfig, ref result)); } }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { return(exportMananger.ExecuteDataToJira(bizFlow, publishToALMConfig, ref result)); }
public override bool ExportExecutionDetailsToALM(BusinessFlow bizFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null) { return(zephyrEntExportManager.ExportExceutionDetailsToALM(bizFlow, ref result, null, exectutedFromAutomateTab, publishToALMConfig)); }