generate-bat-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate BAT Tests
生成BAT测试
Generate a runnable BAT (Blackbox API Testing) BDD suite — DataWeave
files plus a manifest — from a Mule app's source, organized by
quality dimensions, and validated by running it against the live endpoint.
.dwlbat.yaml生成可运行的BAT(Blackbox API Testing)BDD测试套件——包含DataWeave 文件以及清单——基于Mule应用源码,按质量维度组织,并通过针对实时端点运行来验证。
.dwlbat.yamlWhen to Use This Skill
何时使用此技能
Use this skill when users request:
- "Generate BAT tests for this API / app"
- "Write a BAT suite for the orders service"
- "Add black-box API tests / BDD tests against the deployed endpoint"
- "Create Anypoint API Functional Monitoring tests"
- "Extend the existing BAT tests to cover the new error cases"
- "Refresh / fix the BAT suite after the API changed"
Trigger keywords: BAT, BDD, test, black-box test, API functional
monitoring, functional API test, blackbox · generate / write / add / extend /
refresh tests · against the deployed / running / live endpoint.
.dwlDo NOT use this skill for MUnit. MUnit is build-time, in-process, XML, and
XSD-validated — a different tool with a different workflow. BAT runs against a
deployed HTTP endpoint, is DataWeave, and has no XSD: the only gate on
correctness is "it parses AND it passes against the running app". That gate is
this skill's Phase 2.
当用户提出以下请求时使用此技能:
- "为该API/应用生成BAT测试"
- "为订单服务编写BAT测试套件"
- "针对已部署端点添加黑盒API测试/BDD测试"
- "创建Anypoint API Functional Monitoring测试"
- "扩展现有BAT测试以覆盖新的错误场景"
- "API变更后刷新/修复BAT测试套件"
触发关键词: BAT、BDD、测试、黑盒测试、API functional monitoring、功能API测试、blackbox · 生成/编写/添加/扩展/刷新测试 · 针对已部署/运行/实时端点。
.dwl请勿将此技能用于MUnit。 MUnit是构建时、进程内、基于XML和XSD验证的工具——与BAT属于不同工具,工作流也不同。BAT针对已部署的HTTP端点运行,基于DataWeave,且无XSD验证:判断测试正确性的唯一标准是“可解析且针对运行中的应用执行通过”。这也是本技能第二阶段的核心验证环节。
What BAT is (read once before Phase 1)
BAT是什么(进入第一阶段前请阅读)
BAT = Blackbox API Testing, MuleSoft's API Functional Monitoring framework.
A BAT test is a DataWeave BDD file that issues real HTTP requests against
a deployed API and asserts on the responses. It does not import or see the
Mule flows — it is out-of-process and black-box. A suite is a directory of
files, a manifest, a with environment
settings, and a runner. The suite is executed with the CLI:
.
.dwltests/*.dwlbat.yamlconfig/run-bat.shbatbat --config=localBecause there is no XSD and no build-time validator, two things matter more than
in MUnit generation:
- Authoring discipline — the DSL has exact, easy-to-miss rules (see
). The Phase-2 static validator catches the mechanical ones before you spend a round-trip against the endpoint.
references/bat-authoring-rules.md - The run is the gate — a suite is not "done" until has been executed against the live app and every test passes (or each failure is explained in the report). This replaces MUnit's XSD/compile gate.
./run-bat.sh
BAT = Blackbox API Testing,是MuleSoft的API功能监控框架。BAT测试是一个DataWeave 格式的BDD文件,会向已部署的API发送真实HTTP请求并验证响应。它不会导入或查看Mule流——属于进程外的黑盒测试。一个测试套件包含文件目录、清单、存放环境设置的目录,以及运行脚本。套件通过 CLI执行:。
.dwltests/*.dwlbat.yamlconfig/run-bat.shbatbat --config=local由于没有XSD验证和构建时校验工具,相比MUnit生成,以下两点更为重要:
- 编写规范——DSL有严格且容易遗漏的规则(详见)。第二阶段的静态验证器会在你花费时间与端点交互前,先捕获这些机械性错误。
references/bat-authoring-rules.md - 运行即验证——只有当针对运行中的应用执行且所有测试通过(或每个失败都在报告中说明原因)时,套件才算“完成”。这替代了MUnit的XSD/编译验证环节。
./run-bat.sh
Bundled scripts
捆绑脚本
This skill ships scripts under . Invoke them with the tool —
do not inline their contents. is the absolute path you were given
in the "skill is now active" message (the directory containing this ).
Use it for every invocation; do not construct relative paths.
scripts/Bash<skill-dir>SKILL.md../scripts/...| Script | Purpose | Output |
|---|---|---|
| Step 1 — validate toolchain (jq, BAT CLI at | |
| Step 2 — grep the Mule source for | |
| Step 8 — create | suite skeleton on disk |
| Step 9 — static DSL checks (imports, | stderr diagnostics |
此技能在目录下提供了脚本。请使用工具调用它们——不要内联脚本内容。是“技能已激活”消息中提供的绝对路径(包含此的目录)。每次调用都使用该路径;请勿构造相对路径。
scripts/Bash<skill-dir>SKILL.md../scripts/...| 脚本 | 用途 | 输出 |
|---|---|---|
| 步骤1——验证工具链(jq、位于 | |
| 步骤2——在Mule源码中查找 | |
| 步骤8——创建 | 磁盘上的套件骨架 |
| 步骤9——静态DSL检查(导入语句、 | 标准错误输出的诊断信息 |
Workflow shape (two phases)
工作流结构(两个阶段)
This workflow has two phases separated by a hard user-approval gate.
- Phase 1: Test Design (Steps 1–6). Validate the toolchain, read the app's
OpenAPI contract and Mule XML (and, if present, an existing BAT baseline),
build a test inventory tagged by quality dimension, present an Inventory
Summary, and wait for the user to approve. Phase 1 writes nothing into the
suite directory — only the workspace-relative digest and the inventory JSON.
tmp/bat-gen/ - Phase 2: Generate & Run (Steps 7–11). Scaffold the suite, write the
files +
.dwl, run the static validator, run the suite against the live endpoint, and declare completion only after a clean run.bat.yaml
Phase 2 MUST NOT start until Step 6's approval gate has been passed explicitly.
Generating files before the inventory is approved is the highest-impact
failure mode this structure prevents — a wrong dimension split or a fabricated
endpoint becomes N wrong test files.
.dwl此工作流分为两个阶段,中间有严格的用户审批环节。
- 第一阶段:测试设计(步骤1–6)。验证工具链,读取应用的OpenAPI契约和Mule XML(以及现有BAT基线,如果存在),构建按质量维度标记的测试清单,呈现清单摘要,等待用户审批。第一阶段不会向套件目录写入任何内容——仅会在工作区相对路径下生成摘要文件和清单JSON。
tmp/bat-gen/ - 第二阶段:生成与运行(步骤7–11)。搭建套件骨架,编写文件 +
.dwl,运行静态验证器,针对实时端点运行套件,仅在全部运行通过后才宣告完成。bat.yaml
必须在通过步骤6的审批环节后,才能启动第二阶段。在清单获得批准前生成文件是此结构要避免的最高影响故障模式——错误的维度划分或虚构的端点会导致大量错误的测试文件。
.dwlWorkflow-wide discipline (read before Phase 1)
全工作流规范(进入第一阶段前请阅读)
- Black-box only. Tests hit the deployed HTTP API. They never import Mule flows, read the Object Store directly, or assert on internal state. If the user wants in-process flow assertions, that is MUnit, not this skill.
- Endpoints come ONLY from the source. Every path + verb in a generated test
must exist in the app's Mule configuration and OpenAPI contract. Never invent an endpoint from the API's name or from training-time intuition. Step 2's
<http:listener>digest is the anchor; the Phase-2 validator enforces it viaextract_endpoints.sh.--allowlist - Config interpolation, never hardcoding. Every test uses and
$(config.url). A literalconfig.tokenorhttp://localhost...in a"Bearer ..."file is a defect — the validator rejects it..dwl - The run is the gate. "Done" means ran against the live app and every test passed, OR every failure is documented in the report with reasoning. Never declare completion off an unrun suite.
./run-bat.sh - Don't fix the app to make a test pass. If a test reveals what looks like a real bug in the app, do NOT edit the app. Flag it in the report as a discovered discrepancy and make the assertion match what the code actually does, noting the discrepancy for human review.
- 仅黑盒测试。测试仅访问已部署的HTTP API。绝不导入Mule流、直接读取对象存储或断言内部状态。如果用户需要进程内流断言,请使用MUnit,而非此技能。
- 端点仅来自源码。生成测试中的每个路径+方法必须存在于应用的Mule 配置和OpenAPI契约中。绝不要根据API名称或训练时的直觉凭空创建端点。步骤2的
<http:listener>摘要是基础;第二阶段的验证器会通过extract_endpoints.sh参数强制执行此规则。--allowlist - 配置插值,禁止硬编码。每个测试都使用和
$(config.url)。config.token文件中出现字面量.dwl或http://localhost...属于缺陷——验证器会拒绝此类文件。"Bearer ..." - 运行即验证。“完成”意味着针对运行中的应用执行且所有测试通过,或每个失败都在报告中记录并说明原因。绝不能基于未运行的套件宣告完成。
./run-bat.sh - 不要为通过测试修改应用。如果测试发现应用中存在疑似真实bug,请勿编辑应用。在报告中标记为已发现的差异,并调整断言使其匹配代码的实际行为,同时注明该差异需人工审核。
Phase 1: Test Design
第一阶段:测试设计
Step 1: Validate Prerequisites
步骤1:验证先决条件
Run the prerequisite validator. It only validates; it writes findings to
.
tmp/bat-gen-env.jsonbash
bash <skill-dir>/scripts/validate_prerequisites.shIf it exits non-zero, STOP and surface the array to the user
(most commonly: BAT CLI not installed, or Java < 17). Do not attempt to author
a suite you cannot run — the run is the gate, and an unrunnable suite cannot
pass it.
errors运行先决条件验证器。它仅做验证;将结果写入。
tmp/bat-gen-env.jsonbash
bash <skill-dir>/scripts/validate_prerequisites.sh如果退出码非零,请停止操作并向用户展示数组内容(最常见的情况:未安装BAT CLI,或Java版本低于17)。请勿尝试编写无法运行的套件——运行是验证的核心,无法运行的套件无法通过验证。
errorsStep 2: Read the Source and Build the Endpoint Anchor
步骤2:读取源码并构建端点基础
Identify the Mule app directory under test, then run the digest helper to anchor
the inventory in the real source:
bash
bash <skill-dir>/scripts/extract_endpoints.sh <app-dir>This writes and echoes it: the
paths (the endpoint allowlist), the types
(the error-type coverage list), and the API spec file paths.
tmp/bat-gen/source-digest.json<http:listener><raise-error>Then read the actual source — the digest anchors you but does not replace
reading:
- The OpenAPI/RAML contract (paths from ) — request/response shapes, required fields, enums, status codes.
api_specs[] - The Mule flow XML () — verbs per listener path,
src/main/mule/*.xmlbranches,<choice>/<when>mappings to status codes, the state machine if there is one, and howraise-erroris enforced.Authorization - for the runtime context.
mule-artifact.json
[BLOCKER] Do not generate tests from the OpenAPI contract alone. The
contract states intent; the flow XML states behavior. Where they disagree, the
flow XML is what the deployed endpoint actually does, and BAT tests the deployed
endpoint. Note any contract↔code disagreements for the report.
确定被测Mule应用的目录,然后运行摘要辅助工具,基于真实源码为测试清单提供基础:
bash
bash <skill-dir>/scripts/extract_endpoints.sh <app-dir>这会生成并输出该文件内容:包含路径(端点白名单)、类型(错误类型覆盖列表)以及API规范文件路径。
tmp/bat-gen/source-digest.json<http:listener><raise-error>然后读取实际源码——摘要仅作为基础,无法替代直接读取源码:
- OpenAPI/RAML契约(来自的路径)——请求/响应结构、必填字段、枚举值、状态码。
api_specs[] - Mule流XML()——每个监听路径对应的请求方法、
src/main/mule/*.xml分支、<choice>/<when>到状态码的映射、状态机(如果存在),以及raise-error的实现方式。Authorization - ——运行时上下文信息。
mule-artifact.json
[阻塞点] 请勿仅基于OpenAPI契约生成测试。 契约描述的是预期,而流XML描述的是实际行为。当两者不一致时,流XML才是已部署端点的实际行为,而BAT测试的是已部署端点。请在报告中记录任何契约与代码的不一致之处。
Step 3: Read the Existing BAT Baseline (if one exists)
步骤3:读取现有BAT基线(如果存在)
If the app already has a hand-written BAT suite (commonly under or
a directory the user names), read it. It is ground truth for how this team
writes BAT tests — absorb its idioms so the generated suite is consistent:
<app>/bat/- file/test naming style (kebab-case files; double-quoted headers; single-quoted
describe(...)scenarios)it must '...' - the state-seeding pattern (,
var context = HashMap(),execute [ context.set(...) ]in the next URL)$(context.get(...)) - config layout and shape
bat.yaml - which matchers the team uses
When a baseline exists, the generated suite MUST be a strict superset of the
behaviors the baseline covers — no regressions. Re-emit baseline tests (so the
suite stands alone), mark them in the inventory, and do not change
their semantics (you may rename for consistency). If no baseline exists, skip
this step.
existing如果应用已有手写的BAT测试套件(通常位于或用户指定的目录),请读取它。它是团队编写BAT测试的基准——吸收其惯用写法,使生成的套件保持一致:
<app>/bat/- 文件/测试命名风格(短横线分隔文件名;双引号包裹的标题;单引号包裹的
describe(...)场景)it must '...' - 状态初始化模式(、
var context = HashMap()、下一个URL中使用execute [ context.set(...) ])$(context.get(...)) - 配置布局和格式
bat.yaml - 团队使用的匹配器类型
当存在基线时,生成的套件必须是基线覆盖行为的严格超集——不能出现回归。重新生成基线测试(使套件独立存在),在清单中标记为,且不要更改其语义(可重命名以保持一致性)。如果没有基线,请跳过此步骤。
existingStep 4: Draft the Test Inventory
步骤4:草拟测试清单
Using the source (Step 2) and any baseline (Step 3), draft the inventory: one
entry per proposed test, tagged with a primary quality dimension. Use the
taxonomy in .
references/quality-dimensions.mdWrite the inventory to — a JSON array of:
tmp/bat-gen/test-inventory.jsonjson
{
"name": "post-orders-happy-path",
"file": "tests/post-orders-happy-path.dwl",
"dimension": "Accuracy",
"subdimension": "data-integrity",
"endpoint": "POST /orders",
"rationale": "one sentence — why this test is worth running",
"expected_status": 201,
"expected_error_code": null,
"exercises_raise_error_type": null,
"covers": ["Coverage:endpoint", "Accuracy:data-integrity"],
"provenance": "new",
"stateful": false
}- is
provenance|existing|new(when a baseline test is improved — add a one-linerefined). When there is no baseline, everything isrefined_reason.new - marks tests that need a seed call +
stateful: true(multi-step).context - Cover every endpoint × method and every type from the Step-2 digest. Aim for ~12–20 tests for a small API; don't bloat with redundant variants.
raise-error
Names are kebab-case and match the basename.
.dwl基于源码(步骤2)和任何现有基线(步骤3),草拟测试清单:每个拟议测试对应一个条目,标记主要质量维度。使用中的分类体系。
references/quality-dimensions.md将清单写入——一个JSON数组,每个条目格式如下:
tmp/bat-gen/test-inventory.jsonjson
{
"name": "post-orders-happy-path",
"file": "tests/post-orders-happy-path.dwl",
"dimension": "Accuracy",
"subdimension": "data-integrity",
"endpoint": "POST /orders",
"rationale": "一句话说明——为什么值得运行此测试",
"expected_status": 201,
"expected_error_code": null,
"exercises_raise_error_type": null,
"covers": ["Coverage:endpoint", "Accuracy:data-integrity"],
"provenance": "new",
"stateful": false
}- 取值为
provenance|existing|new(当基线测试被改进时——添加一行refined)。如果没有基线,所有条目均为refined_reason。new - 标记需要种子调用 +
stateful: true的测试(多步骤)。context - 覆盖所有端点×方法,以及步骤2摘要中的所有类型。小型API目标为约12–20个测试;避免冗余变体导致套件臃肿。
raise-error
名称使用短横线分隔格式,与文件的基础名一致。
.dwlStep 5: Derive the Endpoint Allowlist
步骤5:生成端点白名单
Write the normalized endpoint allowlist the Phase-2 validator will check
generated paths against — one path per line, with id segments collapsed to :
{}/orders
/orders/{}
/orders/{}/confirm
/orders/{}/ship
/orders/{}/cancelSave it to . Derive it from the Step-2
(plus base path), NOT from the inventory — it is the
independent check on the inventory.
tmp/bat-gen/endpoint-allowlist.txtlistener_paths[]生成第二阶段验证器将用于检查生成路径的标准化端点白名单——每行一个路径,将ID段替换为:
{}/orders
/orders/{}
/orders/{}/confirm
/orders/{}/ship
/orders/{}/cancel保存到。基于步骤2的(加上基础路径)生成,而非基于测试清单——它是对清单的独立校验。
tmp/bat-gen/endpoint-allowlist.txtlistener_paths[]Step 6: Present the Inventory Summary and Get Approval
步骤6:呈现清单摘要并获取审批
[BLOCKER] Present ONLY after Steps 1–5 are complete. Every inventory entry
must have a dimension, an endpoint that exists in the allowlist, and an expected
status. If any is missing or an endpoint is not in the allowlist, fix it before
presenting — do not paper over with "TBD".
Present a concise summary:
**BAT Test Inventory Summary**
**App under test:** <app dir> · runtime URL <config.url>
**Source read:** <OpenAPI spec path>, <flow XML path(s)>
**Baseline:** <none | N existing tests at <path>>
**Coverage:**
- Endpoints: <M of N listener paths × methods covered>
- raise-error types: <list each type from the digest and the test that triggers it; flag any not covered>
- State transitions: <list, if the app has a state machine>
**Inventory (<count> tests):**
- By dimension: Accuracy <n> · Robustness <n> · Security <n>
- By provenance: existing <n> · new <n> · refined <n> (omit if no baseline)
**Items flagged for human review:**
- <contract↔code disagreements, suspicious validation, dead branches — or "none">Then ask for explicit approval:
Review the inventory above. Proceed to generate and run the suite (Phase 2)?
- Yes, generate and run the suite.
- No, I want to change the inventory.
- No, cancel.
[BLOCKER] WAIT for explicit "Yes" before Step 7. On "change the inventory",
ask what to change (coverage, dimensions, specific tests) and loop back. On
"cancel", stop politely.
[阻塞点] 仅在步骤1–5完成后呈现。 每个清单条目必须包含维度、存在于白名单中的端点,以及预期状态。如果有任何缺失或端点不在白名单中,请在呈现前修复——不要用“待确定”敷衍。
呈现简洁的摘要:
**BAT测试清单摘要**
**被测应用:** <应用目录> · 运行时URL <config.url>
**已读取源码:** <OpenAPI规范路径>、<流XML路径>
**基线:** <无 | N个现有测试位于<路径>>
**覆盖情况:**
- 端点:<M/N个监听路径×方法已覆盖>
- raise-error类型:<列出摘要中的每个类型及触发它的测试;标记未覆盖的类型>
- 状态转换:<列出(如果应用有状态机)>
**清单(共<count>个测试):**
- 按维度划分:Accuracy <n> · Robustness <n> · Security <n>
- 按来源划分:existing <n> · new <n> · refined <n> (无基线时省略)
**需人工审核的条目:**
- <契约与代码不一致、可疑的验证逻辑、死分支——或“无”>然后请求明确审批:
请审核以上清单。是否继续生成并运行测试套件(第二阶段)?
- 是,生成并运行测试套件。
- 否,我要修改清单。
- 否,取消操作。
[阻塞点] 等待明确的“是”答复后再进入步骤7。 如果用户选择“修改清单”,询问具体修改内容(覆盖范围、维度、特定测试)并返回步骤4调整。如果选择“取消”,礼貌地停止操作。
Phase 2: Generate & Run
第二阶段:生成与运行
Step 7: (Re)confirm the Runtime URL and Token
步骤7:(重新)确认运行时URL和令牌
The suite runs against a live endpoint. Confirm the URL and bearer token before
scaffolding:
- If the user gave a URL/token, use them.
- If the app is the local fixture, the defaults are
and
http://localhost:8082/api/v1.Bearer test-token - If neither is known, ask via — a suite pointed at the wrong URL fails every test for the wrong reason.
AskUserQuestion
套件针对实时端点运行。搭建套件前请确认URL和Bearer令牌:
- 如果用户提供了URL/令牌,使用它们。
- 如果应用是本地测试环境,默认值为和
http://localhost:8082/api/v1。Bearer test-token - 如果两者都未知,请通过询问——指向错误URL的套件会因错误原因导致所有测试失败。
AskUserQuestion
Step 8: Scaffold the Suite
步骤8:搭建套件骨架
Create the suite skeleton (config, runner, tests dir):
bash
bash <skill-dir>/scripts/scaffold_suite.sh <suite-dir> --url "<config.url>" --token "<bearer>"This writes , (url/token/env),
(chmod +x, with the JDK-17 ), and an empty
. It will not overwrite an existing unless you pass
— respect a url/token the user already edited.
config/default.dwlconfig/local.dwlrun-bat.sh--add-opensJAVA_OPTStests/config/local.dwl--forcePick per the user's project convention (e.g.
or a path the user names). Do not write into the
hand-written baseline directory.
<suite-dir><app>/bat-generated/创建套件骨架(配置文件、运行脚本、测试目录):
bash
bash <skill-dir>/scripts/scaffold_suite.sh <suite-dir> --url "<config.url>" --token "<bearer>"这会生成、(URL/令牌/环境配置)、(添加可执行权限,配置JDK-17的 ),以及空的目录。除非传递参数,否则不会覆盖已有的——尊重用户已编辑的URL/令牌。
config/default.dwlconfig/local.dwlrun-bat.sh--add-opensJAVA_OPTStests/--forceconfig/local.dwl根据用户的项目约定选择(例如或用户指定的路径)。请勿写入手写基线目录。
<suite-dir><app>/bat-generated/Step 9: Write the .dwl
Files and bat.yaml
, then Validate
.dwlbat.yaml步骤9:编写.dwl
文件和bat.yaml
,然后验证
.dwlbat.yamlFor each entry in the inventory whose provenance is not , write
following every rule in
. The canonical shapes are in
— read them and match the style:
droppedtests/<name>.dwlreferences/bat-authoring-rules.mdreferences/examples/- — one request, multiple asserts.
single-call-happy-path.dwl - — negative/error-code test.
auth-401.dwl - — seed call +
multi-step-stateful.dwl+ dependent call (forcontextinventory entries).stateful: true - — asserting a parsed JSON body field and a
json-body-and-headers.dwlheader that carries a charset (see rules 7b/7c).Content-Type
Then write (schema in the authoring rules / ):
, a entry per , and (HTML + JSON). No
top-level key.
bat.yamlreferences/examples/bat.yamlsuite.namefiles:.dwlreporters:config:As the first tool call after writing, run the static validator against the
endpoint allowlist from Step 5:
bash
bash <skill-dir>/scripts/validate_bat_suite.sh <suite-dir> --allowlist tmp/bat-gen/endpoint-allowlist.txtIf it exits non-zero, fix the reported files and re-run the validator. Only
proceed to Step 10 after it exits 0. Keep the validator and the run in separate
responses.
对于清单中来源不为的每个条目,遵循中的所有规则编写。参考中的标准格式——阅读并匹配其风格:
droppedreferences/bat-authoring-rules.mdtests/<name>.dwlreferences/examples/- ——单次请求,多个断言。
single-call-happy-path.dwl - ——负面/错误码测试。
auth-401.dwl - ——种子调用 +
multi-step-stateful.dwl+ 依赖调用(适用于context的清单条目)。stateful: true - ——断言解析后的JSON体字段和带有字符集的
json-body-and-headers.dwl头(见规则7b/7c)。Content-Type
然后编写(格式参考编写规则 / ):包含、每个对应的条目,以及(HTML + JSON)。请勿包含顶层键。
bat.yamlreferences/examples/bat.yamlsuite.name.dwlfiles:reporters:config:完成编写后的第一个工具调用,使用步骤5生成的端点白名单运行静态验证器:
bash
bash <skill-dir>/scripts/validate_bat_suite.sh <suite-dir> --allowlist tmp/bat-gen/endpoint-allowlist.txt如果退出码非零,修复报告中指出的文件并重新运行验证器。只有当退出码为0时,才能进入步骤10。将验证器调用和运行操作分开在不同响应中执行。
Step 10: Run the Suite Against the Live Endpoint
步骤10:针对实时端点运行套件
This is the gate. As the only tool call in this response:
bash
cd <suite-dir> && ./run-bat.shRead the output:
- All tests pass → proceed to Step 11.
- A test fails → diagnose the cause:
- BAT-DSL/syntax error → fix the , re-run the validator (Step 9), then re-run the suite.
.dwl - Assertion you guessed wrong (the app's real behavior differs from what the test asserted) → correct the assertion to match the deployed behavior, and note the correction in the report.
- What looks like a real app bug → do NOT fix the app. Flag it in the report as a discovered discrepancy, set the assertion to match the actual behavior, and mark it for human review.
- Connection refused / every test 401/404 → the runtime is down or the
URL/token is wrong. Fix Step 7's config (re-run or edit
scaffold_suite.sh --force) and re-run. This is not a test defect.config/local.dwl
- BAT-DSL/syntax error → fix the
Iterate until all tests pass OR every remaining failure is documented. Do not
ship a suite with silent failures. Run only in this response — no
other tool calls alongside it.
./run-bat.sh这是核心验证环节。在此响应中仅执行此工具调用:
bash
cd <suite-dir> && ./run-bat.sh读取输出结果:
- 所有测试通过 → 进入步骤11。
- 测试失败 → 诊断原因:
- BAT-DSL/语法错误 → 修复文件,重新运行验证器(步骤9),然后重新运行套件。
.dwl - 断言猜测错误(应用的实际行为与测试断言不符)→ 修正断言使其匹配已部署行为,并在报告中记录此修正。
- 疑似真实应用bug → 请勿修复应用。在报告中标记为已发现的差异,将断言设置为匹配实际行为,并注明需人工审核。
- 连接被拒绝/所有测试返回401/404 → 运行时环境未启动或URL/令牌错误。修复步骤7的配置(重新运行或编辑
scaffold_suite.sh --force)并重新运行。这不属于测试缺陷。config/local.dwl
- BAT-DSL/语法错误 → 修复
迭代直到所有测试通过或所有剩余失败都已记录。请勿交付存在未记录失败的套件。在此响应中仅运行——不要同时执行其他工具调用。
./run-bat.shStep 11: Write the Report and Declare Completion
步骤11:编写报告并宣告完成
Pre-condition: the immediately preceding response ran and you
have its pass/fail output. If not, go back to Step 10.
./run-bat.shWrite a short next to the suite:
REPORT.md- Test count by dimension and by provenance.
- Coverage table: each type and whether a test covers it; each endpoint × method.
raise-error - Pass rate (X/Y) from the run.
- Discrepancies discovered (contract↔code, suspected app bugs) — for human review.
- Any tests still failing and why (only if you could not resolve them and chose to flag rather than silently drop).
Then declare completion in a tight message — the user can see the files and the
run log. Include exactly:
- The suite directory path and test count.
- One sentence on what the suite covers.
- The pass rate from the live run.
- Anything flagged for human review (or "none").
Do not pad with feature lists or next-steps.
前置条件: 上一个响应已运行且你已获取其通过/失败输出。如果未满足,请返回步骤10。
./run-bat.sh在套件旁编写简短的:
REPORT.md- 按维度和来源划分的测试数量。
- 覆盖表:每个类型及是否有测试覆盖;每个端点×方法。
raise-error - 运行通过率(X/Y)。
- 已发现的差异(契约与代码不一致、疑似应用bug)——需人工审核。
- 仍失败的测试及原因(仅当无法解决且选择标记而非静默删除时记录)。
然后用简洁的消息宣告完成——用户可以查看文件和运行日志。消息需包含:
- 套件目录路径和测试数量。
- 一句话说明套件覆盖的内容。
- 实时运行的通过率。
- 需人工审核的内容(或“无”)。
请勿添加功能列表或后续步骤等冗余内容。
Quick Reference
快速参考
bash
undefinedbash
undefinedStep 1: validate toolchain (jq, BAT CLI, Java 17+) — validation-only
步骤1:验证工具链(jq、BAT CLI、Java 17+)——仅做验证
bash <skill-dir>/scripts/validate_prerequisites.sh
bash <skill-dir>/scripts/validate_prerequisites.sh
Step 2: anchor the inventory in the real source
步骤2:基于真实源码为清单提供基础
bash <skill-dir>/scripts/extract_endpoints.sh <app-dir> # → tmp/bat-gen/source-digest.json
bash <skill-dir>/scripts/extract_endpoints.sh <app-dir> # → tmp/bat-gen/source-digest.json
Step 8: scaffold the runnable suite skeleton
步骤8:搭建可运行的套件骨架
bash <skill-dir>/scripts/scaffold_suite.sh <suite-dir> --url "<config.url>" --token "<bearer>"
bash <skill-dir>/scripts/scaffold_suite.sh <suite-dir> --url "<config.url>" --token "<bearer>"
Step 9: static DSL validation before spending a live run
步骤9:实时运行前的静态DSL验证
bash <skill-dir>/scripts/validate_bat_suite.sh <suite-dir> --allowlist tmp/bat-gen/endpoint-allowlist.txt
bash <skill-dir>/scripts/validate_bat_suite.sh <suite-dir> --allowlist tmp/bat-gen/endpoint-allowlist.txt
Step 10: the gate — run against the deployed endpoint
步骤10:核心验证环节——针对已部署端点运行
cd <suite-dir> && ./run-bat.sh
undefinedcd <suite-dir> && ./run-bat.sh
undefinedReferences
参考资料
- — the BAT DSL rules (R1–R10),
references/bat-authoring-rules.mdschema, config files, andbat.yaml. Read before writing anyrun-bat.sh..dwl - — the Accuracy / Robustness / Security / Coverage taxonomy used to tag and size the inventory.
references/quality-dimensions.md - — canonical
references/examples/files (single-call, auth-error, multi-step stateful, JSON body/headers) and a reference.dwl.bat.yaml
- —— BAT DSL规则(R1–R10)、
references/bat-authoring-rules.md格式、配置文件和bat.yaml。编写任何run-bat.sh文件前请阅读。.dwl - —— 用于标记和划分清单的Accuracy / Robustness / Security / Coverage分类体系。
references/quality-dimensions.md - —— 标准
references/examples/文件(单次调用、认证错误、多步骤状态、JSON体/头)和参考.dwl。bat.yaml