zoukankan      html  css  js  c++  java
  • 在Rally上,上传测试报告(文件)到每个Test Case方法

    本文链接: https://www.cnblogs.com/hchengmx/p/how-to-upload-test-result-to-test-case-result-in-rally.html

    JsonObject newTestCaseResult = new JsonObject();
    newTestCaseResult.addProperty("Verdict", verdict);
    newTestCaseResult.addProperty("Date", s1);
    newTestCaseResult.addProperty("Notes", Notes);
    newTestCaseResult.addProperty("Build", Build);
    newTestCaseResult.addProperty("TestCase", testCaseRef);
    newTestCaseResult.addProperty("Tester", getUserReference(restApi, username));
    System.out.println("Test case result request is " + newTestCaseResult);
    CreateRequest  testCaseResultCreateRequest  = new CreateRequest("testcaseresult", newTestCaseResult);
    CreateResponse testCaseResultCreateResponse = restApi.create(testCaseResultCreateRequest);
    

    步骤二:读取文件,把文件的Content转为Base64

    RandomAccessFile myFileHandle = new RandomAccessFile(path, "r");                   
    byte[] fileBytes = new byte[fileLength];
    myFileHandle.readFully(fileBytes);
    String attachmentBase64String = Base64.encodeBase64String(fileBytes);
    

    步骤三:创建类型为AttachmentContent的create request,得到attachmentContentRef

    JsonObject myAttachmentContent = new JsonObject();
    myAttachmentContent.addProperty("Content", attachmentBase64String);
    CreateRequest attachmentContentCreateRequest = new CreateRequest("AttachmentContent", myAttachmentContent);
    CreateResponse attachmentContentResponse = restApi.create(attachmentContentCreateRequest);
    

    步骤四:创建类型为Attachment的create request,其中有test case result属性,值为步骤一得到的ref,content属性,为步骤三得到的ref

    JsonObject myAttachment = new JsonObject();
    myAttachment.addProperty("TestCaseResult", ref);
    myAttachment.addProperty("Content", myAttachmentContentRef);
    myAttachment.addProperty("Name", filename);
    myAttachment.addProperty("Description", "Attachment From Automation");
    myAttachment.addProperty("ContentType", "application/octet-stream");
    myAttachment.addProperty("Size", attachmentSize);
    myAttachment.addProperty("User", getUserReference(restApi, username));
    
    CreateRequest  attachmentCreateRequest = new CreateRequest("Attachment", myAttachment);
    CreateResponse attachmentResponse      = restApi.create(attachmentCreateRequest);
    
  • 相关阅读:
    [CXF REST标准实战系列] 二、Spring4.0 整合 CXF3.0,实现测试接口
    [CXF REST标准实战系列] 一、JAXB xml与javaBean的转换
    项目中使用百度地图遇见的问题
    工作体会(第一次工作)
    第一家公司面试
    自我总结(九)---
    J2EE 第二阶段项目(八)
    J2EE 第二阶段项目之编写代码(六)
    J2EE 第二阶段项目之JUnit4进行单元测试(五)
    J2EE 第二阶段项目之编写代码(四)
  • 原文地址:https://www.cnblogs.com/hchengmx/p/how-to-upload-test-result-to-test-case-result-in-rally.html
Copyright © 2011-2022 走看看