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

步骤一:创建类型为testcaseresult的create request,得到test case result的ref link

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);

在Rally上,上传测试报告(文件)到每个Test Case方法的更多相关文章

  1. upload控件上传json文件合并的两种方法

    方法一: byte[] byte1 = FileUpload1.FileBytes; byte[] byte2 = FileUpload2.FileBytes; byte[] a1 = Encodin ...

  2. linux学习笔记-linux主机上传下载文件至linux虚拟机的方法

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 1.上传文件 scp -r file 用户名@ip地址:目标目录 2.下载文件 scp -r 用户名@ip地址:文件 目标目录

  3. 三种上传文件不刷新页面的方法讨论:iframe/FormData/FileReader

    发请求有两种方式,一种是用ajax,另一种是用form提交,默认的form提交如果不做处理的话,会使页面重定向.以一个简单的demo做说明: html如下所示,请求的路径action为"up ...

  4. struts2实现文件上传(多文件上传)及下载

    一.要实现文件上传,需在项目中添加两个jar文件 二.上传准备的页面 注:必须植入enctype="multipart/form-data"属性,以及提交方式要设置成post &l ...

  5. spring mvc文件上传(单个文件上传|多个文件上传)

    单个文件上传spring mvc 实现文件上传需要引入两个必须的jar包    1.所需jar包:                commons-fileupload-1.3.1.jar       ...

  6. 用百度webuploader分片上传大文件

    一般在做文件上传的时候,都是通过客户端把要上传的文件上传到服务器,此时上传的文件都在服务器内存,如果上传的是视频等大文件,那么服务器内存就很紧张,而且一般我们都是用flash或者html5做异步上传, ...

  7. Linux上传下载文件快捷命令

    远程链接Linux(如SecrueCRT),要上传文件很下载文件到Linux服务器,只需要使用sz或者rz命令即可快速下载和上传文件了. 使用方法: 1.首先确保Linux服务器系统中安装了lrzsz ...

  8. 利用SkyDrive Pro 迅速批量下载SharePoint Server 上已上传的文件

    在上一篇<SharePoint Server 2013 让上传文件更精彩>,我们一起了解了如何快速的方便的上传批量文件到SharePoint Server 2013 ,而在这一篇日志中您将 ...

  9. 用java 代码下载Samba服务器上的文件到本地目录以及上传本地文件到Samba服务器

    引入: 在我们昨天架设好了Samba服务器上并且创建了一个 Samba 账户后,我们就迫不及待的想用JAVA去操作Samba服务器了,我们找到了一个框架叫 jcifs,可以高效的完成我们工作. 实践: ...

  10. [Asp.net]Uploadify上传大文件,Http error 404 解决方案

    引言 之前使用Uploadify做了一个上传图片并预览的功能,今天在项目中,要使用该插件上传大文件.之前弄过上传图片的demo,就使用该demo进行测试.可以查看我的这篇文章:[Asp.net]Upl ...

随机推荐

  1. LazyCaptcha自定义随机验证码和字体

    介绍 LazyCaptcha是仿EasyCaptcha和SimpleCaptcha,基于.Net Standard 2.1的图形验证码模块. 目前Gitee 52star, 如果对您有帮助,请不吝啬点 ...

  2. Python入门-多进程

    1.获取本机CPU # 早期的CPU是单核:实现多个程序并行,在某一时间点,其实只有一个进程 # 后来硬件多核CPU:多个进程是并行执行. from multiprocessing import cp ...

  3. 安装 UE 源码版

    # 安装 UE 源码版 ## 下载安装包 > - 先去 Github 找 UE 官方开源的引擎组(这个需要申请加入) > - 加入后找到开源的源码版项目下载 zip 到本地 > - ...

  4. Java学习day30

    线程分为用户线程和守护线程,虚拟机必须确保用户线程执行完毕,虚拟机不用等待守护线程执完毕 并发:同一个对象被多个线程同时操作,例如上万了同时抢100张票,手机银行和柜台同时取同一张卡里的钱 处理多线程 ...

  5. JavaScript学习总结8-DOM

    今天学习了DOM的增删改查 innerText可以用来修改文本的内容,但是无法识别标签,要修改标签样式使用innerHTML 删除节点的步骤:先获取父节点,在通过父节点删除子节点 注意:删除节点是一个 ...

  6. 详解javascript的eventloop(一)

    先看一段代码 console.log('Hi') setTimeOut(function cb1(){ console.log('cb1') },500) console.log('Bye') 第一步 ...

  7. JS加载不出来 必须alert才可以 alert另一种功能

    BEGIN; 今天在引入百度编辑器时,发现百度编辑器加载不出来. 代码是这样的: var editor = new baidu.editor.ui.Editor({    textarea: 'con ...

  8. 论文解读(DCRN)《Deep Graph Clustering via Dual Correlation Reduction》

    论文信息 论文标题:Deep Graph Clustering via Dual Correlation Reduction论文作者:Yue Liu, Wenxuan Tu, Sihang Zhou, ...

  9. 软件工程-UML各种图总结-精华

    ​ UML(Unified Modeling Language)是一种统一建模语言,为面向对象开发系统的产品进行说明.可视化.和编制文档的一种标准语言.下面将对UML的九种图+包图的基本概念进行介绍以 ...

  10. BootstrapBlazor实战 Menu 导航菜单使用(1)

    实战BootstrapBlazorMenu 导航菜单的使用, 以及整合Freesql orm快速制作菜单项数据库后台维护页面 demo演示的是Sqlite驱动,FreeSql支持多种数据库,MySql ...