HP Quality Center (QC) 是一款由惠普公司开发的测试管理工具,用于管理软件测试过程。它提供了丰富的功能,包括测试计划、测试用例、缺陷跟踪等。HP QC REST API 是一套基于HTTP协议的接口,允许外部应用程序与HP QC进行交互。
类型:
应用场景:
以下是一个使用Postman调用HP QC REST API的基本示例:
请求URL:
https://your-qc-server/qcbin/api/domains/{domain}/projects/{project}/test-set-folders/{folder-id}/test-sets/{set-id}/test-instances?query={{"id":{test-case-id}}}
请求方法:GET
Headers:
Authorization: Basic {base64-encoded-username-password}
Content-Type: application/json
示例代码(JavaScript):
const axios = require('axios');
const url = 'https://your-qc-server/qcbin/api/domains/your-domain/projects/your-project/test-set-folders/your-folder-id/test-sets/your-set-id/test-instances';
const auth = Buffer.from('username:password').toString('base64');
axios.get(url, {
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
请求URL:
https://your-qc-server/qcbin/api/domains/{domain}/projects/{project}/defects
请求方法:POST
Headers:
Authorization: Basic {base64-encoded-username-password}
Content-Type: application/json
请求体:
{
"Fields": {
"BG_SEVERITY": "1 - Critical",
"BG_STATUS": "New",
"BG_SUMMARY": "Sample defect summary",
"BG_DESCRIPTION": "Detailed description of the defect"
}
}
示例代码(JavaScript):
const axios = require('axios');
const url = 'https://your-qc-server/qcbin/api/domains/your-domain/projects/your-project/defects';
const auth = Buffer.from('username:password').toString('base64');
const defectData = {
"Fields": {
"BG_SEVERITY": "1 - Critical",
"BG_STATUS": "New",
"BG_SUMMARY": "Sample defect summary",
"BG_DESCRIPTION": "Detailed description of the defect"
}
};
axios.post(url, defectData, {
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log('Defect created:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
问题1:401 Unauthorized
问题2:404 Not Found
问题3:500 Internal Server Error
对于与HP QC的集成,推荐使用Postman作为REST客户端工具。Postman提供了友好的界面和强大的功能,便于开发和调试API请求。
希望这些信息对你有所帮助!如果有更多具体问题,欢迎继续咨询。
领取专属 10元无门槛券
手把手带您无忧上云