go-testing

JamesPrial 的头像作者 JamesPrial

Go 测试模式。路由到特定模式

📖 中文导读:Go 测试模式。路由到特定模式 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: go-testing description: Go testing patterns. Routes to specific patterns.

Testing

Route by Pattern

Quick Check

  • Tests named Test_Function_Scenario
  • Table tests for >2 cases
  • Helpers call t.Helper()
  • Parallel tests capture loop vars

Common Patterns

Basic test structure:

func Test_Function_Scenario(t *testing.T) {
    // Arrange
    input := "test"

    // Act
    result := Function(input)

    // Assert
    if result != expected {
        t.Errorf("got %v, want %v", result, expected)
    }
}