claude-code/claude-zh/commands/go-test.md

28 lines
851 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# /go-test — Go 測試自動化
執行 Go 專案測試、分析覆蓋率並自動修復失敗的測試案例。
## 使用方式
```bash
/go-test [package-path] [--cover] [--fix]
```
## 功能說明
1. **執行測試**:執行 `go test ./...`
2. **分析失敗案例**:找出失敗的測試原因、斷言不匹配或發生 Panic 的位置。
3. **自動修復**:嘗試修正實作代碼或測試期望值。
4. **覆蓋率報告**:產生詳細的程式碼覆蓋率分析。
## 引數 (Arguments)
- `[package-path]`:指定特定的 Package例如 `./internal/utils`
- `--cover`:顯示百分比覆蓋率報告。
- `--fix`:當測試失敗時,自動嘗試修復程式碼。
## 注意事項
- 使用此指令前,請確保 `go.mod` 已正確配置。
- 對於大型專案,建議指定 Package 路徑以節省資源。