如何通过c#将附件添加到ALM OTA中的测试集?

我运行以下代码但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 = @"Root\YourFolder";

        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 Files\\ApplicationName\\demoAttach.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();
                    }
                }
            }
        }
    }
}

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...