SKILL

golang-testing

Go testing patterns including table-driven tests, subtests, benchmarks, fuzzing, and test coverage. Follows TDD methodology with idiomatic Go practices.

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Go 測試模式
  • 何時啟用
  • Go 的 TDD 工作流程
  • RED-GREEN-REFACTOR 循環
  • Go 中的逐步 TDD
  • 表格驅動測試
  • 帶錯誤案例的表格驅動測試
  • 子測試

用於撰寫可靠、可維護測試的完整 Go 測試模式,遵循 TDD 方法論。 撰寫新的 Go 函式或方法 為現有程式碼增加測試覆蓋率 為效能關鍵程式碼建立基準測試 實作輸入驗證的模糊測試 在 Go 專案中遵循 TDD 工作流程 Go 測試的標準模式。以最少程式碼達到完整覆蓋。 使用儲存在 testdata/ 中的預期輸出檔案進行測試。 | 程式碼類型 | 目標 | |-----------|------| | 關鍵業務邏輯 | 100% | | 公開 API | 90%+ | | 一般程式碼 | 80%+ | | 產生的程式碼 | 排除 | 應該做的: 先寫測試(TDD) 使用表格驅動測試以獲得完整覆蓋 測試行為,而非實作 在輔助函式中使用 t.Helper() 對獨立測試使用 t.Parallel() 用 t.Cleanup() 清理資源 使用描述情境的有意義測試名稱 不應該做的: 不要直接測試私有函式(透過公開 API 測試) 不要在測試中使用 time.Sleep()(使用 channels 或條件) 不要忽略不穩定測試(修復或移除它們) 不要 mock 所有東西(可能時偏好整合測試) 不要跳過錯誤路徑測試 記住:測試是文件。它們展示你的程式碼應該如何使用。清楚地撰寫並保持更新。

Source repository
affaan-m/ECC
Source file
docs/zh-TW/skills/golang-testing/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.752Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.