SKILL

golang-testing

Go 测试最佳实践,包括表驱动测试、测试辅助函数、基准测试、竞态检测、覆盖率分析和集成测试模式。适用于编写或改进 Go 测试。

译文已校对
查看英文原文

Go testing best practices including table-driven tests, test helpers, benchmarking, race detection, coverage analysis, and integration testing patterns. Use when writing or improving Go tests.

适用对象:软件开发与测试。自动收录 · 待核查。

原作者说明节选

从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。

查看英文原文

原文涵盖的主题

  • Go Testing
  • Testing Framework
  • Table-Driven Tests
  • Test Helpers
  • Test Fixtures
  • Race Detection
  • Coverage Analysis
  • Basic Coverage

This skill provides comprehensive Go testing patterns extending common testing principles with Go-specific idioms. Use the standard go test with table-driven tests as the primary pattern. The idiomatic Go testing pattern: Benefits: Easy to add new test cases Clear test case documentation Parallel test execution with t.Parallel() Isolated subtests with t.Run() Use t.Helper() to mark helper functions: Benefits: Correct line numbers in test failures Reusable test utilities Cleaner test code Use t.Cleanup() for resource cleanup: Always run tests with the -race flag to detect data races: In CI/CD: Why: Detects concurrent access bugs Prevents production race conditions Minimal performance overhead in tests Run benchmarks: Compare benchmarks: Run integration tests: 1. Use t.Parallel() for independent tests 2. Use testing.Short() to skip slow tests 3. Use t.TempDir() for temporary directories 4. Use t.Setenv() for environment variables 5. Avoid init() in test files 6. Keep tests focused - one behavior per test 7. Use meaningful test names - describe what's being tested Writing new Go tests Improving test coverage Setting up test infrastructure Debugging flaky tests Optimizing test performa

这里只展示节选,请以完整原文和当前要求为准。

来源仓库
affaan-m/ECC
源文件
.kiro/skills/golang-testing/SKILL.md
固定版本
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
阅读完整原作者说明 ↗

来源与内容状态

本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。

原作者:affaan-m/ECC · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-09T14:01:48.602Z。

分类由名称、说明与路径规则生成,分类不代表已核实适配。

许可与权利归属

MIT。第三方内容及版权归原作者,使用条件以原文为准。

许可原文 ↗

本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。

限制与注意事项

  • 元数据收录不代表本站已经安装、适配、实测或进行安全审查。