如何通过c#将附件添加到ALM OTA中的测试集?
发布时间:2020-12-15 08:46:26 所属栏目:百科 来源:网络整理
导读:我运行以下代码但ALM中没有显示任何内容: AttachmentFactory attachmentFactory = (AttachmentFactory)tsTest.Attachments;TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem("test");attachment.Post(); 第二行的Ad
我运行以下代码但ALM中没有显示任何内容:
AttachmentFactory attachmentFactory = (AttachmentFactory)tsTest.Attachments; TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem("test"); attachment.Post(); 第二行的AddItem方法一直在询问“对象ItemData”,但我不知道究竟是什么.惠普的文档很差,实际上并没有解释它.有谁知道如何以编程方式使用c#将文件附件添加到HP ALM中的测试运行中? 解决方法
经过多次痛苦和研究后,我找到了答案.我确信还有其他方法可以实现更高效,但由于HP的文档是地球上最糟糕的,这是我能想到的最好的.如果有人有更好的方式我会喜欢看到它所以请发布它!
我希望这有帮助! try { if (qcConn.Connected) { string testFolder = @"RootYourFolder"; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConn.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder); AttachmentFactory attchFactory = (AttachmentFactory)tsFolder.Attachments; List tsList = tsFolder.FindTestSets("YourTestNameHere",false,null); foreach (TestSet ts in tsList) { TestSetFolder tstFolder = (TestSetFolder)ts.TestSetFolder; TSTestFactory tsTestFactory = (TSTestFactory)ts.TSTestFactory; List mylist = tsTestFactory.NewList(""); foreach (TSTest tsTest in mylist) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; Run run = (Run)runFactory.AddItem("NameYouWantDisplayedInALMRuns"); run.CopyDesignSteps(); //runResult just tells me if overall my test run passes or fails - it's not built in. It was my way of tracking things though the code. if(runResult) run.Status = "Failed"; else run.Status = "Passed"; run.Post(); //Code to attach an actual file to the test run. AttachmentFactory attachmentFactory = (AttachmentFactory)run.Attachments; TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value); attachment.Description = "Attach via c#"; attachment.Type = 1; attachment.FileName = "C:Program FilesApplicationNamedemoAttach.txt"; attachment.Post(); //Code to attach a URL to the test run AttachmentFactory attachmentFactory = (AttachmentFactory)run.Attachments; TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value); //Yes,set the description and FileName to the URL. attachment.Description = "http://www.google.com"; attachment.Type = 2; attachment.FileName = "http://www.google.com"; attachment.Post(); //If your testset has multiple steps and you want to update //them to pass or fail StepFactory rsFactory = (StepFactory)run.StepFactory; dynamic rdata_stepList = rsFactory.NewList(""); var rstepList = (TDAPIOLELib.List)rdata_stepList; foreach (dynamic rstep in rstepList) { if (SomeConditionFailed) rstep.Status = "Failed"; else rstep.Status = "Passed"; rstep.Post(); } else { rstep.Status = "No Run"; rstep.Post(); } } } } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |