如何通过 Rally 添加验证输入和预期结果 API
How to add Validation input and expected result via Rally API
我在 rally 中成功创建了一个新的测试用例。在新的测试用例中,我想添加 'Steps' 以及验证输入和预期结果。
我已成功添加 'Steps' 但我无法添加验证输入和预期结果。
有人知道怎么做吗?
我正在使用 JAVA。
谢谢
这是一个代码示例,它在退出 TestCase 时使用 Input 和 ExpectedResult 创建 TestSteps:
public class AddStepsToTestCase {
public static void main(String[] args) throws Exception {
String host = "https://rally1.rallydev.com";
String apiKey = "_abc123";
String applicationName = "Add Steps To TC";
String workspaceRef = "/workspace/12343";
RallyRestApi restApi = null;
try {
restApi = new RallyRestApi(new URI(host), apiKey);
restApi.setApplicationName(applicationName);
QueryRequest request = new QueryRequest("TestCase");
request.setFetch(new Fetch("FormattedID", "Name", "Steps"));
request.setWorkspace(workspaceRef);
request.setQueryFilter(new QueryFilter("FormattedID", "=", "TC18"));
QueryResponse response = restApi.query(request);
JsonObject testCaseJsonObject = response.getResults().get(0).getAsJsonObject();
String testCaseRef = testCaseJsonObject.get("_ref").getAsString();
int numberOfSteps = testCaseJsonObject.getAsJsonObject("Steps").get("Count").getAsInt();
System.out.println(testCaseJsonObject.get("Name") + " ref: " + testCaseRef + "number of steps: " + numberOfSteps + " " + testCaseJsonObject.get("Steps"));
if (response.wasSuccessful()) {
JsonObject stepOne = new JsonObject();
JsonObject stepTwo = new JsonObject();
stepOne.addProperty("Input", "Open Database Connection");
stepOne.addProperty("StepIndex", 1);
stepOne.addProperty("StepIndex", 2);
stepOne.addProperty("TestCase", testCaseRef);
stepTwo.addProperty("Input", "2+2");
stepTwo.addProperty("ExpectedResult", "4");
stepTwo.addProperty("TestCase", testCaseRef);
CreateRequest createRequest = new CreateRequest("testcasestep", stepOne);
CreateResponse createResponse = restApi.create(createRequest);
CreateRequest createRequest2 = new CreateRequest("testcasestep", stepTwo);
CreateResponse createResponse2 = restApi.create(createRequest2);
}else {
System.out.println("false? " + response.wasSuccessful());
}
} finally {
if (restApi != null) {
restApi.close();
}
}
}
}
UI中的结果:
我在 rally 中成功创建了一个新的测试用例。在新的测试用例中,我想添加 'Steps' 以及验证输入和预期结果。
我已成功添加 'Steps' 但我无法添加验证输入和预期结果。
有人知道怎么做吗?
我正在使用 JAVA。
谢谢
这是一个代码示例,它在退出 TestCase 时使用 Input 和 ExpectedResult 创建 TestSteps:
public class AddStepsToTestCase {
public static void main(String[] args) throws Exception {
String host = "https://rally1.rallydev.com";
String apiKey = "_abc123";
String applicationName = "Add Steps To TC";
String workspaceRef = "/workspace/12343";
RallyRestApi restApi = null;
try {
restApi = new RallyRestApi(new URI(host), apiKey);
restApi.setApplicationName(applicationName);
QueryRequest request = new QueryRequest("TestCase");
request.setFetch(new Fetch("FormattedID", "Name", "Steps"));
request.setWorkspace(workspaceRef);
request.setQueryFilter(new QueryFilter("FormattedID", "=", "TC18"));
QueryResponse response = restApi.query(request);
JsonObject testCaseJsonObject = response.getResults().get(0).getAsJsonObject();
String testCaseRef = testCaseJsonObject.get("_ref").getAsString();
int numberOfSteps = testCaseJsonObject.getAsJsonObject("Steps").get("Count").getAsInt();
System.out.println(testCaseJsonObject.get("Name") + " ref: " + testCaseRef + "number of steps: " + numberOfSteps + " " + testCaseJsonObject.get("Steps"));
if (response.wasSuccessful()) {
JsonObject stepOne = new JsonObject();
JsonObject stepTwo = new JsonObject();
stepOne.addProperty("Input", "Open Database Connection");
stepOne.addProperty("StepIndex", 1);
stepOne.addProperty("StepIndex", 2);
stepOne.addProperty("TestCase", testCaseRef);
stepTwo.addProperty("Input", "2+2");
stepTwo.addProperty("ExpectedResult", "4");
stepTwo.addProperty("TestCase", testCaseRef);
CreateRequest createRequest = new CreateRequest("testcasestep", stepOne);
CreateResponse createResponse = restApi.create(createRequest);
CreateRequest createRequest2 = new CreateRequest("testcasestep", stepTwo);
CreateResponse createResponse2 = restApi.create(createRequest2);
}else {
System.out.println("false? " + response.wasSuccessful());
}
} finally {
if (restApi != null) {
restApi.close();
}
}
}
}
UI中的结果: