0

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

我的代码:

私人附件 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;
    }
4

4 回答 4

1

事实上,它现在有效。Attachment 对象现在有一个属性 TestCaseResult,当设置该属性时,会将附件附加到创建的结果中。我修改后的代码:

   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;
      }
于 2012-06-12T18:31:19.420 回答
0

自 2012 年 5 月 26 日 Rally 代码发布以来,此缺陷已得到修复。

于 2012-05-29T22:57:47.523 回答
0

不幸的是,您遇到了 Rally Webservices API 的一个已知缺陷。Rally 产品开发部门正在努力修复 - 尽管如此,我还是建议向 Rally 支持 (rallysupport@rallydev.com) 提交一个案例,因为这会将您的查询与缺陷相关联,并且在修复后您会收到通知。

于 2012-04-29T20:08:21.210 回答
0

如果附件属于 test_case_result 它应该使用 attachment.artifact:

Artifact
Required    false
Note    The artifact this attachment belongs to.
One-To-One Relationship Artifact

为什么我们需要 Attachment.TestCaseResult 而不是简单的 Attachment.Artifact ?

TestCaseResult    
Required    false
Note    Associated Test Case Result
One-To-One Relationship TestCaseResult
于 2012-06-19T19:53:23.863 回答