8.6 文件格式参考

本章列出批量测试涉及的文件格式,便于人工检查、对比差异或用脚本生成。日常使用无需手工编辑这些文件。

8.6.1 测试用例文件(.tst)

<?xml version="1.0" encoding="UTF-8"?>
<UDM-TST>
    <uuid>3f0d9c25-6a3e-4a1b-9c6f-2b1f0e7d5a44</uuid>
    <targetFile uuid="0e4d4af0-b89f-49ad-8dd2-e914e5417d6d" type="sca" path="规则/评分卡示例.sca"/>
    <compareOptions mode="strict" numericTolerance="0" ignoreExtraFields="true" maxDiffsPerCase="50">
        <ignorePath><![CDATA[traceId]]></ignorePath>
        <whitelistPath><![CDATA[resultCode]]></whitelistPath>
    </compareOptions>
    <templateConfig format="json" withExpected="true" savePath="规则/评分卡示例.testcases.json">
        <inputPath><![CDATA[age]]></inputPath>
        <expectedPath><![CDATA[resultCode]]></expectedPath>
    </templateConfig>
    <item name="成年客户">
        <desc><![CDATA[年龄 30 的客户应命中 A 档]]></desc>
        <input><![CDATA[{"age":30}]]></input>
        <expected><![CDATA[{"resultCode":"A"}]]></expected>
    </item>
    <item name="未成年客户">
        <desc><![CDATA[年龄 16 的客户应命中 C 档]]></desc>
        <input><![CDATA[{"age":16}]]></input>
        <expected><![CDATA[{"resultCode":"C"}]]></expected>
    </item>
</UDM-TST>
节点 / 属性 说明
<uuid> 测试文件自身的唯一标识,执行与导入模板时用于定位文件
<targetFile uuid type path> 被测文件信息,type 为扩展名小写
<compareOptions mode numericTolerance ignoreExtraFields maxDiffsPerCase> 文件级比对设置,见 8.3
<ignorePath> / <whitelistPath> 逐条路径,使用 CDATA 保存,便于书写 items[].status 这类写法
<templateConfig format withExpected savePath> JSON 模板生成配置,见 8.5
<inputPath> / <expectedPath> 模板勾选的属性路径
<item name> 一条测试用例,name 为用例名称
<desc> / <input> / <expected> 用例描述、输入数据、预期结果,均为 JSON 对象的文本,未设置时写 {}

说明:

  • 路径类节点也兼容整段文本写法(<ignorePaths> / <whitelistPaths> 内换行分隔),以及写在同名属性上的形式;
  • 缺少 <compareOptions> / <templateConfig> 时按默认设置处理;
  • 执行结果不写入本文件,用例的名称、描述、输入数据与预期结果之外的内容都不会被序列化。

8.6.2 测试结果文件(.testrun.json)

导出结果的文件名为 <测试文件名>.testrun.<YYYYMMDD-HHmmss>.json,内容示例:

{
  "version": 1,
  "savedAt": "2026-11-09T02:35:10.000Z",
  "fileUuid": "3f0d9c25-6a3e-4a1b-9c6f-2b1f0e7d5a44",
  "ruleFile": "规则/评分卡示例.sca",
  "compareOptions": {
    "mode": "strict",
    "ignorePaths": ["traceId"],
    "whitelistPaths": [],
    "numericTolerance": 0,
    "ignoreExtraFields": true,
    "maxDiffsPerCase": 50
  },
  "cases": [
    {
      "name": "成年客户",
      "desc": "年龄 30 的客户应命中 A 档",
      "input": "{\"age\":30}",
      "expected": "{\"resultCode\":\"A\"}",
      "passed": true,
      "elapse": 12,
      "output": { "resultCode": "A" }
    }
  ],
  "summary": {
    "executed": 1,
    "passed": 1,
    "failed": 0,
    "skipped": 1,
    "elapse": 96
  }
}
字段 说明
version 结果文件版本,当前为 1,高于当前版本时会提示可能不兼容
savedAt 导出时间(ISO 8601)
fileUuid / ruleFile 测试文件与被测文件信息,导入时用于比对提示
compareOptions 导出时的比对设置
cases[].passed 服务端判定结论;缺省表示该用例未参与执行
cases[].elapse 单条耗时(毫秒)
cases[].output / cases[].log 实际出参与执行日志,未开启日志时不包含日志
summary.executed / passed / failed / skipped / elapse 执行条数、通过数、未通过数、跳过数、整体耗时

导入该文件时按用例名称匹配,名称找不到时按行号兜底,只叠加结果,不改动 .tst 文件内容。

results matching ""

    No results matching ""