SoapUI是一个开源的API测试工具,主要用于测试SOAP和REST风格的Web服务。它提供了图形界面和Groovy脚本支持,可以创建复杂的测试场景。
Rally(现为Broadcom Agile Central)是一个敏捷项目管理工具,提供API用于与系统交互,包括创建和管理测试用例。
REST(Representational State Transfer)是一种架构风格,Rally提供了REST API用于程序化操作其数据。
https://rally1.rallydev.com/slm/webservice/v2.0/
/testcase/create
Content-Type: application/json
ZSESSIONID: [你的API密钥]
{
"TestCase": {
"Name": "示例测试用例",
"Description": "通过SoapUI创建的测试用例",
"WorkProduct": "/hierarchicalrequirement/12345", // 关联的用户故事ID
"Method": "手动",
"Type": "功能",
"Owner": "/user/67890", // 测试用例所有者ID
"Priority": "高",
"ValidationInput": "测试输入条件",
"ValidationExpectedResult": "预期结果",
"Project": "/project/54321" // 项目ID
}
}
问题: 收到401 Unauthorized响应 原因: API密钥无效或过期 解决:
问题: 收到400 Bad Request响应,提示关联对象不存在 原因: 提供的WorkProduct或Project ID不正确 解决:
问题: 收到400 Bad Request响应,提示字段验证失败 原因: 必填字段缺失或字段值不符合要求 解决:
如果你需要在SoapUI中使用Groovy脚本更灵活地创建测试用例:
import groovy.json.JsonOutput
// 设置请求
def request = testRunner.testCase.testSteps["CreateTestCase"].testRequest
def headers = request.requestHeaders
headers["Content-Type"] = "application/json"
headers["ZSESSIONID"] = "你的API密钥"
request.requestHeaders = headers
// 构建请求体
def testCaseData = [
TestCase: [
Name: "自动化创建的测试用例",
Description: "通过Groovy脚本创建",
WorkProduct: "/hierarchicalrequirement/12345",
Method: "自动化",
Type: "功能",
Priority: "高",
Project: "/project/54321"
]
]
request.requestContent = JsonOutput.toJson(testCaseData)
// 执行请求
def response = request.submit(context.getProperty("request"), context.getProperty("response"))
// 检查响应
if (response.statusCode == 201) {
log.info "测试用例创建成功"
def jsonSlurper = new groovy.json.JsonSlurper()
def result = jsonSlurper.parseText(response.responseContent)
log.info "创建的测试用例ID: ${result.CreateResult.Object._refObjectUUID}"
} else {
log.error "创建失败: ${response.responseContent}"
}
通过以上方法,你可以有效地使用SoapUI的REST功能在Rally中创建和管理测试用例。
没有搜到相关的文章