Loading...
Loading...
Compare original and translation side by side
前置条件:先阅读。若旧总入口与本 skill 的领域规则冲突,以当前 CLI help 和本 skill 为准。涉及接口定义时按当前 CLI help 使用 endpoint、schema、folder 等命令;涉及多步骤流程时读取../apifox-cli/SKILL.md。../apifox-test-scenario/SKILL.md
cli-schema validategetPrerequisites: Readfirst. If there is a conflict between the old main entry and the domain rules of this skill, follow the current CLI help and this skill. When involving interface definitions, use commands like endpoint, schema, folder according to the current CLI help; when involving multi-step processes, read../apifox-cli/SKILL.md.../apifox-test-scenario/SKILL.md
cli-schema validategetapifox-test-scenarioapifox-test-automationtest-reportapifox-test-automationapifox-test-scenarioapifox-test-automationtest-reportapifox-test-automation| 概念 | CLI 资源 | 说明 |
|---|---|---|
| 接口测试用例 | | 绑定接口 endpoint 的测试数据与步骤 |
| 测试分类 | | 测试用例分类;创建 case 前用于获取有效 |
| 测试数据集 | | 可供迭代运行的数据 |
| 接口定义 | | case 的依赖对象,不等同 case 本身 |
| 测试场景 | | 多步骤流程编排,边界不同 |
| Concept | CLI Resource | Description |
|---|---|---|
| API Test Case | | Test data and steps bound to an API endpoint |
| Test Category | | Test case category; used to obtain valid |
| Test Dataset | | Data available for iterative runs |
| API Definition | | Dependent object of a case, not equivalent to the case itself |
| Test Scenario | | Multi-step process orchestration with different boundaries |
test-casetest-dataapifox run --test-casetest-case categorycategoryIdtest-case category--endpointtest-case list --endpoint <endpointId>apifox run --test-caseapifox-test-scenarioapifox test-scenario import-steps <scenarioId> --project <projectId> --source test-case --endpoint <endpointId> --ids <testCaseIds> --sync manualtest-casetest-dataapifox run --test-casetest-case categorycategoryIdtest-case category--endpointtest-case list --endpoint <endpointId>apifox run --test-caseapifox-test-scenarioapifox test-scenario import-steps <scenarioId> --project <projectId> --source test-case --endpoint <endpointId> --ids <testCaseIds> --sync manualapifox endpoint list/getapifox test-case category --project <projectId>categoryIdapifox test-case list --project <projectId> --endpoint <endpointId>apifox test-case list --project <projectId> --endpoint <endpointId>gettest-case-createtest-case get <caseId>test-reportapifox-test-automationcategoryIdcategoryIdget/listtest-case categoryapifox endpoint list/getapifox test-case category --project <projectId>categoryIdapifox test-case list --project <projectId> --endpoint <endpointId>apifox test-case list --project <projectId> --endpoint <endpointId>gettest-case-createtest-case get <caseId>test-reportapifox-test-automationcategoryIdcategoryIdget/listtest-case categorygettest-case-updateupdatetest-case-createtest-case-updatetest-case-updatetypedataextractorvariableType/subject/shareScopeassertionsubject/comparisondelaydatatest-case getmethodtest-case-updategettest-case-updateupdatetest-case-createtest-case-updatetest-case-updatedatatypeextractorvariableType/subject/shareScopeassertionsubject/comparisondatadelaymethodtest-case gettest-case-updatetest-case getapifox-cli-checkuptest-case getapifox-cli-checkuprequestBody.data\npreProcessorspostProcessors{ id, type, data, defaultEnable, enable }{ type, config }idassertionextractorcustomScriptiddata.variableTypeglobalsdata.shareScopePROJECTTEAMcli-schema validatetest-case get{
"requestBody": {
"type": "application/json",
"data": "{\n \"name\": \"Demo\",\n \"description\": \"Readable in client\"\n}"
},
"postProcessors": [
{
"id": "postProcessors.0.customScript",
"type": "customScript",
"data": "pm.test('返回 ID', function () {\n var body = pm.response.json();\n pm.expect(body.data.id).to.exist;\n});",
"defaultEnable": true,
"enable": true
},
{
"id": "postProcessors.1.extractor",
"type": "extractor",
"data": {
"variableName": "project_pet_name",
"variableType": "globals",
"shareScope": "PROJECT",
"subject": "responseJson",
"expression": "$.name"
},
"defaultEnable": true,
"enable": true
}
]
}requestBody.data\npreProcessorspostProcessors{ id, type, data, defaultEnable, enable }{ type, config }idassertionextractorcustomScriptidglobalsdata.variableTypePROJECTdata.shareScopeTEAMcli-schema validatetest-case get{
"requestBody": {
"type": "application/json",
"data": "{\n \"name\": \"Demo\",\n \"description\": \"Readable in client\"\n}"
},
"postProcessors": [
{
"id": "postProcessors.0.customScript",
"type": "customScript",
"data": "pm.test('返回 ID', function () {\n var body = pm.response.json();\n pm.expect(body.data.id).to.exist;\n});",
"defaultEnable": true,
"enable": true
},
{
"id": "postProcessors.1.extractor",
"type": "extractor",
"data": {
"variableName": "project_pet_name",
"variableType": "globals",
"shareScope": "PROJECT",
"subject": "responseJson",
"expression": "$.name"
},
"defaultEnable": true,
"enable": true
}
]
}assertionassertioncustomScripthttpCoderesponseCoderesponseJsonresponseBodyresponseTextincludeequalequals{
"type": "assertion",
"data": {
"name": "HTTP 状态码为 200",
"subject": "httpCode",
"comparison": "equal",
"value": "200",
"path": ""
},
"defaultEnable": true,
"enable": true
}pmpm.test(...)pm.testpm.response.json()pm.environment.set("variable_key", "variable_value");
pm.variables.set("variable_key", "variable_value");
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("JSON value equals expected", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100);
});assertionassertioncustomScripthttpCoderesponseCoderesponseJsonresponseBodyresponseTextincludeequalequals{
"type": "assertion",
"data": {
"name": "HTTP 状态码为 200",
"subject": "httpCode",
"comparison": "equal",
"value": "200",
"path": ""
},
"defaultEnable": true,
"enable": true
}pmpm.test(...)pm.response.json()pm.testpm.environment.set("variable_key", "variable_value");
pm.variables.set("variable_key", "variable_value");
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("JSON value equals expected", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100);
});test-scenariotest-casecategoryIdtest-case getmethodtest-case-update{{$.1.response...}}forEachtest-scenariotest-scenario import-steps --source test-caseget --with-case-detailtest-scenariotest-casecategoryIdmethodtest-case gettest-case-update{{$.1.response...}}forEachtest-scenariotest-scenario import-steps --source test-caseget --with-case-detailtest-case run <caseId>test-case run --endpoint <endpointId>--category <categoryId>--endpoint <endpointId>apifox run --test-case <caseId>--environmentcli-schema validatetest-case gettest-case run <caseId>test-case run --endpoint <endpointId>--category <categoryId>--endpoint <endpointId>apifox run --test-case <caseId>--environmentcli-schema validatetest-case get| 现象 | 处理 |
|---|---|
| 测试步骤不展示 | |
| 断言不生效 | 读取现有成功 case 模板,对比 assertion 字段 |
| 提取变量为空 | 检查 extractor 层级、变量名、响应路径和执行报告 |
| run-config 404 | 确认 case/endpoint/environment/branch 均存在,再转 |
| endpoint 下找不到 case | 检查是否带了正确 |
| Phenomenon | Handling |
|---|---|
| Test steps not displaying | Check the actual structure with |
| Assertions not taking effect | Read existing successful case templates and compare assertion fields |
| Variable extraction returns empty | Check extractor level, variable name, response path and execution report |
| run-config 404 | Confirm that case/endpoint/environment/branch all exist, then switch to |
| Cannot find case under endpoint | Check if the correct |