Rally SOAP API - 如何向 TestCaseResult 添加附件 [英] Rally SOAP API - How do I add an attachment to a TestCaseResult

查看:54
本文介绍了Rally SOAP API - 如何向 TestCaseResult 添加附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经想出了如何向 TestCase、Defect 对象添加附件,但我无法使用相同的机制将测试结果文件附加到 TestCaseResult 对象.我收到验证错误:Attachment.attachments[0] 不应为空"的错误消息.我尝试在创建测试结果期间附加以及更新现有的、先前创建的测试结果.如果不支持将测试结果文件附加到 TestCaseResult ,我会感到惊讶,因为这是常见的主流行为.谢谢.

I have figured out how to add an attachment to TestCase, Defect objects, but I can't, using the same mechanism, seem to attach a test result file to a TestCaseResult object. I am getting an error message of "validation error: Attachment.attachments[0] should not be null". I've tried attaching during the creation of the test result as well as updating an existing, previously created, test result. I would be surprised if attaching a test result file to a TestCaseResult is not supported as this is common mainstream behavior. Thanks.

我的代码:

私有附件 createAttachment(string resultsFile){byte[] bytes = readFileAsByteArray(resultsFile);

private Attachment createAttachment(string resultsFile) { byte[] bytes = readFileAsByteArray(resultsFile);

        // Create attachment content;
        AttachmentContent attachmentContent = new AttachmentContent();
        attachmentContent.Content = bytes;
        attachmentContent.Workspace = this.m_targetWorkspace;
        CreateResult result = m_rallyService.create(attachmentContent);
        attachmentContent = (AttachmentContent)result.Object;
        //attachmentContent = (AttachmentContent)this.m_rallyService.read(attachmentContent, this.m_targetWorkspace);


        Attachment attachment = new Attachment();
        attachment.ContentType = "application / vnd.openxmlformats - officedocument.wordprocessingml.document";
        attachment.Content = attachmentContent;
        attachment.Name = "Bubba.docx";
        attachment.Size = bytes.Length;
        attachment.SizeSpecified = true;
        attachment.User = this.m_rallyUser;
        //attachment.Artifact = testResult;
        attachment.Workspace = this.m_targetWorkspace;

        result = m_rallyService.create(attachment);
        attachment = (Attachment)result.Object;
        //attachment = (Attachment)this.m_rallyService.read(attachment, this.m_targetWorkspace);

        return attachment;
    }

推荐答案

实际上它现在可以工作了.Attachment 对象现在有一个属性 TestCaseResult ,当设置时,将附件附加到创建的结果.我修改后的代码:

In deed it now works. The Attachment object now has an attribute TestCaseResult which when set, attaches the attachment to the created result. My revised code:

   private Attachment createAttachment(TestCaseResult testCaseResult, string resultsFile)
    {
        byte[] bytes = readFileAsByteArray(resultsFile);

        // Create attachment content;
        AttachmentContent attachmentContent = new AttachmentContent();
        attachmentContent.Content = bytes;
        attachmentContent.Workspace = this.m_targetWorkspace;
        CreateResult result = m_rallyService.create(attachmentContent);
        attachmentContent = (AttachmentContent)result.Object;

        // Create attachment.
        Attachment attachment = new Attachment();

        // Microsoft Word document.
        attachment.ContentType = "application / vnd.openxmlformats - officedocument.wordprocessingml.document";
        attachment.Content = attachmentContent;

        // Parse out file name.
        string[] parts = resultsFile.Split(new char[] { '\\' });
        attachment.Name = parts[parts.Length - 1];

        attachment.Size = bytes.Length;
        attachment.SizeSpecified = true;
        attachment.User = this.m_rallyUser;
        attachment.TestCaseResult = testCaseResult;
        attachment.Workspace = this.m_targetWorkspace;

        result = m_rallyService.create(attachment);
        attachment = (Attachment)result.Object;

        return attachment;
      }

这篇关于Rally SOAP API - 如何向 TestCaseResult 添加附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆