我正在成功地在拉力赛中创建一个新的测试用例。在新的测试用例中,我想添加“步骤”'以及验证输入和预期结果。
我已设法添加'步骤'但我无法添加验证输入和预期结果。
任何人都知道如何做到这一点?
我正在使用JAVA。
由于
答案 0 :(得分:1)
以下是在退出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();
}
}
}
}
用户界面中的结果: