随笔 - 49  文章 - 0  评论 - 20  阅读 - 12万

代码调用Rally的接口介绍

本文链接: https://www.cnblogs.com/hchengmx/p/test-framework-integrate-with-rally.html


1. 支持的语言

根据官方GitHub显示,https://github.com/RallyTools

目前支持的语言有 Python, NodeJs, .Net, Clojure, Ruby, Java, PHP..

以下均以Java举例。

其中Get/Query/Create用的比较多,所以只介绍了这几种。更多的请求可参考 官方API文档

2. 创建API Key

API Key可以理解为替代了账号密码。

Rally Application Manager 中Create New API Keys

创建以后,需要在代码中引用API Keys

RallyRestApi restApi = new RallyRestApi(new URI(host), "API Keys");

3. GetRequest

得到某Referance的详细参数(Get the specified object.)

String ref =  Ref.getRelativeRef(testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString()); //testcase/457072321724
GetRequest getRequest = new GetRequest(ref);
GetResponse getResponse = restApi.get(getRequest);

4. QueryRequest

QueryRequest testCaseQueryRequest = new QueryRequest("TestCase");
testCaseQueryRequest.setFetch(new Fetch(new String[]{testCaseID, "Name", "FormattedID"}));
QueryFilter queryFilter = new QueryFilter("FormattedID", "=", testCaseID);
testCaseQueryRequest.setQueryFilter(queryFilter);
QueryResponse testCaseQueryResponse = restApi.query(testCaseQueryRequest);

5. CreateRequest

比如遇到情况,一个资源是另外一个资源的其中属性,比如Test Case Result必须是某一个Test Case的,Test Case是Test Case Result的其中一个属性,这种需要先根据Test CaseId找到Test Case Reference,然后Test Case Result再引用。

QueryResponse testCaseQueryResponse = restApi.query(testCaseQueryRequest);
String testCaseRef = testCaseQueryResponse.getResults().get(0).getAsJsonObject().get("_ref").getAsString(); //get test case reference
 
JsonObject newTestCaseResult = new JsonObject();
newTestCaseResult.addProperty("Verdict", verdict);
newTestCaseResult.addProperty("Date", s1);
newTestCaseResult.addProperty("Notes", Notes);
newTestCaseResult.addProperty("Build", Build);
newTestCaseResult.addProperty("TestCase", testCaseRef);
 
CreateRequest  testCaseResultCreateRequest  = new CreateRequest("testcaseresult", newTestCaseResult);
CreateResponse testCaseResultCreateResponse = restApi.create(testCaseResultCreateRequest);

6. 参考资料

  1. Rally Software Introduction
  2. GitHub - RallyTools/RallyRestToolkitForJava: A Java Toolkit for Accessing Rally's Webservice API
  3. CA Agile Central Web Services API Documentation v2.0
  4. For Developers
  5. Agile Central App SDK 2.1 Docs
  6. CA Agile Central - Webhooks(beta)
  7. RallyRestApi (Rally Rest Toolkit For Java 2.2.1 API)
posted on   hchengmx  阅读(139)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示