diff --git a/README.MD b/README.MD index d3dc05d..6b9383a 100644 --- a/README.MD +++ b/README.MD @@ -476,6 +476,23 @@ go run ./cmd/ds2api-tests \ npm ci --prefix webui && npm run build --prefix webui ``` +## 测试 + +详细测试指南请参阅 [TESTING.md](TESTING.md)。 + +### 快速测试命令 + +```bash +# 运行所有单元测试 +go test ./... + +# 运行 tool calls 相关测试(调试工具调用问题) +go test -v -run 'TestParseToolCalls|TestRepair' ./internal/util/ + +# 运行端到端测试 +./tests/scripts/run-live.sh +``` + ## Release 自动构建(GitHub Actions) 工作流文件:`.github/workflows/release-artifacts.yml` diff --git a/TESTING.md b/TESTING.md index c5e13e6..8d1a309 100644 --- a/TESTING.md +++ b/TESTING.md @@ -173,6 +173,50 @@ rg "" artifacts/testsuite//server.log go test ./... ``` +### 运行特定模块的单元测试 + +```bash +# 运行 tool calls 相关测试(推荐用于调试 tool call 解析问题) +go test -v -run 'TestParseToolCalls|TestRepair' ./internal/util/ + +# 运行单个测试用例 +go test -v -run TestParseToolCallsWithDeepSeekHallucination ./internal/util/ + +# 运行 format 相关测试 +go test -v ./internal/format/... + +# 运行 adapter 相关测试 +go test -v ./internal/adapter/openai/... +``` + +### 调试 Tool Call 问题 | Debugging Tool Call Issues + +当遇到 DeepSeek 工具调用解析问题时,可以使用以下方法: + +```bash +# 1. 运行 tool calls 相关的所有测试 +go test -v -run 'TestParseToolCalls|TestRepair' ./internal/util/ + +# 2. 查看测试输出中的详细调试信息 +go test -v -run TestParseToolCallsWithDeepSeekHallucination ./internal/util/ 2>&1 + +# 3. 检查具体测试用例的修复效果 +# 测试用例位于 internal/util/toolcalls_test.go,包含: +# - TestParseToolCallsWithDeepSeekHallucination: DeepSeek 典型幻觉输出 +# - TestRepairLooseJSONWithNestedObjects: 嵌套对象的方括号修复 +# - TestParseToolCallsWithMixedWindowsPaths: Windows 路径处理 +``` + +### 运行 Node.js 测试 + +```bash +# 运行 Node 测试 +node --test tests/node/stream-tool-sieve.test.js + +# 或使用脚本 +./tests/scripts/run-unit-node.sh +``` + ### 跑端到端测试(跳过 preflight) ```bash