2012-04-29 33 views
0

我已經想出瞭如何將附件添加到TestCase,Defect對象,但是我不能使用相同的機制,將測試結果文件附加到一個TestCaseResult對象。我收到「驗證錯誤:Attachment.attachments [0]不應爲空」的錯誤消息。我在創建測試結果的過程中嘗試過附加,並且更新了以前創建的現有測試結果。如果不支持將測試結果文件附加到TestCaseResult,我會感到驚訝,因爲這是常見的主流行爲。謝謝。Rally SOAP API - 如何將附件添加到TestCaseResult

我的代碼:

私人附件createAttachment(串resultsFile) { 字節[]字節= 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; 
    } 

回答

0

不幸的是,您遇到了使用Rally Webservices API的已知缺陷。拉力賽產品開發正在進行修復 - 我建議儘可能向拉力賽支持部([email protected])提交一個案例,因爲這會將您的查詢與缺陷聯繫起來,並在修復後通知您。

0

截至2012年5月26日拉力賽代碼發佈,該缺陷已得到修復。

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; 
     } 
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 
+0

TestCaseResults不是工件,它們是WorkspaceDomainObjects。所以你必須使用TestCaseResult屬性。 – 2012-07-10 17:13:57

相關問題