代码调用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. 参考资料
- Rally Software Introduction
- GitHub - RallyTools/RallyRestToolkitForJava: A Java Toolkit for Accessing Rally's Webservice API
- CA Agile Central Web Services API Documentation v2.0
- For Developers
- Agile Central App SDK 2.1 Docs
- CA Agile Central - Webhooks(beta)
- RallyRestApi (Rally Rest Toolkit For Java 2.2.1 API)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 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,欢迎大家贡献代码