【发布时间】:2014-05-09 14:55:16
【问题描述】:
我使用 C# 中的 Rally Rest API Ver 2.0.1.0 创建了一个应用程序,使我的测试工程师能够使用 CSV 文件以自动方式修改 Rally 测试数据。
我希望应用程序能够找到现有的测试集,获取该集中的测试用例列表,向该列表添加更多测试用例,然后使用新的测试用例列表更新测试集。
我的问题是,当我得到测试集中的测试用例列表时,即使测试集中有超过 20 个测试用例,Rally 也只返回 20 个测试用例。
为了得到测试集中的测试用例列表,这里是我的代码(我很抱歉没有所有的声明,但我想你明白了):
public ArrayList testSetList = new ArrayList();
Request requestTS = new Request("TestSet");
requestTS.Project = rallyProjectRef;
requestTS.ProjectScopeDown = false;
requestTS.ProjectScopeUp = false;
requestTS.Fetch = new List<string> { "Name", "ObjectID", "Iteration", "TestCases" };
requestTS.Query = new Query("Name", Query.Operator.Equals, testSetName).And(new Query("Iteration", Query.Operator.Equals, currentIterationRef));
try
{
QueryResult findTSMatchQueryResult = m.myRestApi.Query(requestTS);
string currentTestSetRef = "/TestSet/" + findTSMatchQueryResult.Results.First()["ObjectID"];
string testCasesintheTestSEt = currentTestSetRef + "/TestCases";
DynamicJsonObject item = m.myRestApi.GetByReference(testCasesintheTestSEt, "TestCase", "ObjectID");
foreach (var testCaseObject in item["Results"])
{
testSetList.Add(testCaseObject);
}
循环遍历GetByReference 方法的结果时,只返回了20 个测试用例对象。有没有办法让我使用这个 GetByReference 方法来扩展返回对象的数量?或者是否可以设置一个查询来获取测试集中测试用例对象的完整列表?
我使用上述方法是因为我注意到当使用 Update 方法“更新”测试集中的测试用例时,Rally 将清除所有现有数据,并将新的测试用例列表视为完整的测试用例集在测试集中。也许还有另一种方法可以在不清除现有测试用例的情况下将测试用例添加到现有测试集中?
目前,当尝试更新测试集中的测试用例时,我使用以下代码,如果testCaseList 不包含先前存在的测试用例,则从测试集中删除已经存在的测试用例。
DynamicJsonObject toUpdate = new DynamicJsonObject();
toUpdate["TestCases"] = testCasesList;
try
{
OperationResult updateOperationResult = m.myRestApi.Update(currentTestSetRef, toUpdate);
if (updateOperationResult.Success == true)
{
return "Added the test case to the test set. ";
}
else
{
return "Error. An error occurred trying to update the test case list of the test set. ";
}
}
catch (Exception)
{
return "Error. An exception occurred trying to update the test cases list of the test set. ";
}
任何帮助将不胜感激。
【问题讨论】: