English version: README_EN.md
这是一套可直接拷贝到 VS Code / GitHub Copilot 自定义目录中使用的模板项目,目标是帮助团队建立如下工作流:
- 从产品 Spec / 需求文档中提取可测试需求
- 从需求生成结构化测试用例
- 由主 agent + subagent 并行补全 testcase 覆盖率
- 通过 coverage auditor 做去重、补洞、命名规范化、覆盖率审计
- 自动判定测试用例属于:自动化 / 半自动 / 手工
- 对可自动化用例生成脚本骨架
- 为执行结果生成证据包与报告模板
这不是单纯的 prompt 集合,而是一套面向工业自动化产品测试的 AI 测试设计与自动化模板仓骨架。
适用对象包括:
- HMI
- PLC
- 变频器(VFD)
- 伺服(Servo)
- Modbus 接口
- OPC UA 接口
适用目标包括:
- Spec → requirement → testcase
- testcase 并行生成与 coverage 审计
- auto / semi-auto / manual 分流
- HMI / 协议层脚本生成
- evidence / report 结构化输出
industrial-copilot-template/
├─ .github/
│ └─ copilot/
│ ├─ instructions/
│ │ └─ industrial-testing.instructions.md
│ ├─ prompts/
│ │ ├─ 01_spec_to_requirements.prompt.md
│ │ ├─ 02_requirements_to_testcases.prompt.md
│ │ ├─ 03_testcase_automation_triage.prompt.md
│ │ ├─ 04_testcase_to_script.prompt.md
│ │ ├─ 05_evidence_pack_generator.prompt.md
│ │ ├─ 06_test_report_generator.prompt.md
│ │ ├─ hmi/
│ │ ├─ plc/
│ │ ├─ modbus/
│ │ └─ opcua/
│ └─ agents/
│ ├─ spec-analyst.agent.md
│ ├─ test-designer.agent.md
│ ├─ automation-triage.agent.md
│ ├─ script-generator.agent.md
│ ├─ evidence-reporter.agent.md
│ ├─ orchestrator.agent.md
│ ├─ parallel-testcase-orchestrator.agent.md
│ └─ coverage-auditor.agent.md
├─ artifacts/
├─ logs/
├─ reports/
├─ tests/
│ ├─ playwright/
│ └─ pytest/
├─ templates/
├─ examples/
├─ governance/
├─ subagent-task-templates/
├─ config/
├─ .env.example
├─ pytest.ini
├─ playwright.config.ts
└─ package.json
对于你的目标,建议建立 Agent,因为这不是单一步骤任务,而是稳定的多阶段工作流。
推荐角色:
- Spec Analyst:读取 Spec,提取 requirement
- Test Designer:生成测试用例
- Automation Triage:判断 auto / semi-auto / manual
- Script Generator:仅对 scriptable 用例生成脚本
- Evidence Reporter:生成 evidence checklist 和报告
- Orchestrator:统一编排调用顺序
- Parallel Testcase Orchestrator:把 Spec 拆成多个子任务并行生成 testcase
- Coverage Auditor:做覆盖率审计、去重、补洞建议
因为工业产品 spec 往往混合了:
- 功能行为
- 异常与边界
- 恢复与稳定性
- 权限与安全
- 日志与证据
- 协议层行为
单一 agent 容易:
- 漏边界场景
- 漏恢复场景
- 漏权限类场景
- 重复 testcase
- 让 automation 判定前后不一致
并行生成 + coverage 审计更适合追求覆盖更完善的 testcase 设计。
- 简单场景:只用
orchestrator一个 agent 串行调用 prompt - 中型场景:
orchestrator+ 5 个专职 agent - 强覆盖场景:
parallel-testcase-orchestrator+ 多个 subagent +coverage-auditor - 大型场景:再按产品线或协议拆 subagent
Spec
→ requirement extraction
→ parallel testcase generation
→ coverage audit / dedup / gap fill
→ automation triage
→ script generation(only auto + scriptable)
→ evidence pack
→ report
01_spec_to_requirements.prompt.md02_requirements_to_testcases.prompt.md03_testcase_automation_triage.prompt.md04_testcase_to_script.prompt.md05_evidence_pack_generator.prompt.md06_test_report_generator.prompt.md
01_spec_to_requirements.prompt.md02_requirements_to_testcases.prompt.md03_testcase_automation_triage.prompt.mdprompts/hmi/hmi_testcase_to_playwright.prompt.md05_evidence_pack_generator.prompt.md06_test_report_generator.prompt.md
prompts/plc/plc_protocol_requirement_extractor.prompt.md02_requirements_to_testcases.prompt.md03_testcase_automation_triage.prompt.mdprompts/plc/plc_testcase_to_pytest.prompt.md05_evidence_pack_generator.prompt.md06_test_report_generator.prompt.md
prompts/modbus/modbus_requirement_to_testcases.prompt.md03_testcase_automation_triage.prompt.mdprompts/modbus/modbus_testcase_to_pytest.prompt.md05_evidence_pack_generator.prompt.md06_test_report_generator.prompt.md
prompts/opcua/opcua_requirement_to_testcases.prompt.md03_testcase_automation_triage.prompt.mdprompts/opcua/opcua_testcase_to_pytest.prompt.md05_evidence_pack_generator.prompt.md06_test_report_generator.prompt.md
parallel-testcase-orchestrator.agent.mdcoverage-auditor.agent.mdsubagent-task-templates/functional.mdnegative-boundary.mdrecovery-robustness.mdsecurity-permission.mdobservability-evidence.md
templates/coverage-matrix.template.yamlgovernance/dedup-rules.mdgovernance/testcase-naming.mdgovernance/parallel-generation-playbook.mdexamples/parallel/spec_split_example.mdexamples/parallel/coverage_audit_example.yaml
对中等复杂工业 spec,推荐拆成 5 个 subagent:
- functional
- negative-boundary
- recovery-robustness
- security-permission
- observability-evidence
如果协议行为很重,再追加:
- Modbus specialist
- OPC UA specialist
- HMI specialist
- PLC specialist
- 检查每个 requirement 是否被覆盖
- 检查是否存在 positive / negative / boundary / recovery coverage
- 检查是否漏掉权限、安全、日志、证据类 case
- 做重复 testcase 识别与去重记录
- 统一 testcase ID 和命名规则
- 输出 gap list 和 follow-up 建议
git clone <your-public-repo-url>
cd industrial-copilot-templatecp .env.example .env根据你的测试环境修改:
- HMI 地址与账号
- Modbus 主机、端口、站号、寄存器
- OPC UA endpoint、namespace、node id
建议自行创建虚拟环境并安装所需依赖,例如:
python -m venv .venv
source .venv/bin/activate
pip install pytest
# 按你的协议场景补充:pymodbus / opcua / asyncua / pyserial 等运行示例:
pytestnpm install
npx playwright install
npm run test:hmi优先从低风险案例开始:
- HMI 登录 / 权限
- Modbus 非法功能码 / 非法地址
- OPC UA browse / read / unauthorized write rejection
- 参数配置合法值 / 非法值
本模板已提供最小工程壳,方便直接作为测试项目起点:
.env.examplepytest.iniplaywright.config.tspackage.jsontests/pytest/conftest.pytests/pytest/test_placeholder.pytests/playwright/example_hmi.spec.tsconfig/project-structure.md
artifacts/:截图、抓包、导出的诊断信息、状态快照logs/:执行日志、调试日志reports/:Markdown / HTML 报告tests/playwright/:HMI / Web UI 自动化tests/pytest/:协议与 Python 脚本测试
本模板默认采用保守策略:
- 未明确批准时,不生成危险运动命令
- 未明确批准时,不生成功率级相关动作
- 涉及急停 / STO / 联锁 / 高速运动 / 电机拖动的测试,默认不直接自动化
- 厂商私有寄存器、对象字典、控制字、状态字未知时,输出 TODO,不猜测
- 真机行为不明确时,优先输出 simulator / stub 占位
- script generation 仅建议用于
auto + scriptable的 testcase
这部分不是保守过头,而是工业测试里保护人、设备和线体的基本护栏。
以下内容建议团队按需自行安装或接入。
- 链接:https://github.com/github/github-mcp-server
- 用途:
- 测试用例 / 缺陷 / PR / 提测结论串联
- 自动生成 issue 草稿
- 把 requirement 和代码变更关联起来
- 链接:https://github.com/microsoft/playwright-mcp
- 用途:
- HMI / Web 管理页自动化
- 让 Agent 更稳定理解 UI 元素与页面结构
- 链接:https://github.com/MarketSquare/robotframework-browser
- 适用:HMI / Web UI
- 链接:https://github.com/MarketSquare/robotframework-requests
- 适用:HTTP / REST API
- 链接:https://github.com/whosaysni/robotframework-seriallibrary
- 适用:串口、调试口、CLI 设备交互
- OPC UA:建议 Python 生态(如 opcua / asyncua)
- Modbus TCP/RTU:建议 pymodbus
- S7:如环境匹配,可考虑 python-snap7
- Serial:pyserial
如果团队要进一步扩展,可考虑让 Copilot / Agent 平台接入:
- GitHub / Issue 管理插件
- 文档知识库插件
- 内部错误码 / 协议字典检索插件
- 测试平台结果回填插件
如果平台支持 hooks,建议只做低风险自动动作:
- 生成脚本后自动执行格式化
- 生成脚本后自动插入日志/超时模板
- 输出 testcase 后自动检查 schema 字段是否齐全
- 输出报告前自动补 traceability 检查
不建议 通过 hooks 自动触发:
- 真机动作
- 参数写入设备
- 升级设备
- 电机运动
- 安全联锁测试
.github/copilot/prompts/hmi/hmi_spec_to_testcases.prompt.md.github/copilot/prompts/hmi/hmi_testcase_to_playwright.prompt.mdexamples/chains/hmi_login_flow.mdexamples/hmi/generated/example_playwright_test.tstemplates/playwright_hmi_test.ts
.github/copilot/prompts/plc/plc_protocol_requirement_extractor.prompt.md.github/copilot/prompts/plc/plc_testcase_to_pytest.prompt.mdexamples/chains/plc_modbus_flow.mdexamples/plc/generated/example_pytest_modbus.py
.github/copilot/prompts/modbus/modbus_requirement_to_testcases.prompt.md.github/copilot/prompts/modbus/modbus_testcase_to_pytest.prompt.mdtemplates/pytest_modbus_test.pyexamples/chains/modbus_invalid_request_flow.mdexamples/modbus/generated/example_modbus_pytest.py
.github/copilot/prompts/opcua/opcua_requirement_to_testcases.prompt.md.github/copilot/prompts/opcua/opcua_testcase_to_pytest.prompt.mdtemplates/pytest_opcua_test.pyexamples/chains/opcua_browse_read_flow.mdexamples/opcua/generated/example_opcua_pytest.py
推荐做法:
- 将本项目中的
.github/copilot/整个拷贝到目标仓库 - 将
templates/、examples/、governance/、subagent-task-templates/一并带过去 - 将
.env.example、pytest.ini、playwright.config.ts、package.json一并带过去 - 结合你们的产品、协议、命名规范做轻微定制
优先从这些场景开始:
- HMI 登录 / 权限
- 参数配置页面
- Modbus 读写与错误响应
- OPC UA browse / read / unauthorized write rejection
- 用主 agent 切分 spec
- 用多个 subagent 并行出 testcase 草稿
- 用 coverage auditor 去重与补洞
- 仅对
auto + scriptablecase 生成脚本 - 保持 manual / semi-auto 场景仍由人控边界
当前采用 MIT License,便于团队和社区复用、修改和二次集成。
当前公开仓库使用更克制的公开写法:
Copyright (c) 2026 nxl801
这样更适合公开发布场景;如果你后续想改成公司名义、组织名义或 contributors 形式,也可以再调整。
本模板已包含:
- Instructions
- 通用 Prompt files
- HMI / PLC / Modbus / OPC UA 专版 Prompt files
- Agents
- 并行 testcase 生成框架
- Subagent 编排建议
- Schema templates
- Governance 规则
- 工程壳(Playwright / pytest 起步结构)
- 示例链路
- 示例脚本
- 中文 README
可以直接作为你在 VS Code / GitHub Copilot 下的起始模板使用。