我已经想出了如何将附件添加到 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;
}