SuperAPI AI 工具集

testing_protocol

测试与质量

查看项目

更新于 10-16 05:58

技能介绍

Testing Protocol 是一个测试工作流技能,其系统提示围绕 Modified-Code Protocol(修改代码协议)设计,用于在代码修改后智能选择需要执行的测试。

用途

该技能的目标是根据本次代码改动的范围,自动判断应该执行哪一类测试,从而避免不必要的全量测试或遗漏必要的验证。它通过检测 Git 工作区中的文件变更来完成这一判断。

主要能力

Modified-Code Protocol 包含三个步骤:

第一步,识别被修改的文件。smart_test_runner 会自动检测:已暂存文件(通过 git diff --cached --name-only)、未暂存文件(通过 git diff --name-only)、未跟踪文件(通过 git ls-files --others)。

第二步,对变更进行分类。检测规则如下:

  • docs_only:路径包含 .md、.txt、.rst、.adoc,动作为跳过测试。
  • mcp_server:路径中包含 mcp-server/,仅执行 MCP 测试。
  • tool_router:路径中包含 tool-router/,仅执行 MCP 测试。
  • nix_config:路径中包含 .nix 或 devenv,执行完整测试套件。
  • code_changes:涉及 .py、.nix、.yaml 等,执行完整测试套件。

第三步,执行相应的测试。跳过时立即返回并说明理由;仅 MCP 时运行 just test-mcp-only;完整测试时运行 just test。

使用方式

该技能提供以下工具和调用方式:

  • smart_test_runner(最常用):await smart_test_runner(),自动决定测试内容。
  • 带 focus 的 smart_test_runner:await smart_test_runner(focus_file="src/agent/tests/test_phase13.py"),在明确知道要测什么时使用。
  • run_test_command:await run_test_command(command="just test-mcp-only"),在需要运行特定测试命令时使用。
  • get_test_protocol:await get_test_protocol(),用于提醒自己协议规则。

测试命令参考:just test 运行完整测试套件;just test-unit 仅运行单元测试;just test-int 运行集成测试;just test-mcp 运行 MCP 测试(包含 mcp 测试);just test-mcp-only 仅运行 MCP 测试;pytest path 用于指定文件或目录。

适用场景

文档修改后调用 smart_test_runner(),返回 {"strategy": "skip", "reason": "Docs only - skipping tests"}。

修改 MCP 服务器代码后调用 smart_test_runner(),返回 {"strategy": "mcp_only", "command": "just test-mcp-only"}。

修改 Nix 配置后调用 smart_test_runner(),返回 {"strategy": "full", "command": "just test"}。

在 Python 代码中进行缺陷修复后调用 smart_test_runner(),返回 {"strategy": "full", "command": "just test"}。

限制

资料中未提供关于该技能支持的平台、收费方式、价格或实际运行效果的信息,相关内容暂未提供。