claudegoodies
Skill

golang-testing

From affaan-m

Patrones de pruebas Go incluyendo pruebas basadas en tablas, subpruebas, benchmarks, fuzzing y cobertura de código. Sigue la metodología TDD con prácticas idiomáticas de Go.

Provides Go testing patterns and templates (table-driven tests, subtests, benchmarks, fuzzing, TDD workflow).

Use it when

  • Writing new Go functions/methods with tests
  • Adding test coverage to existing Go code
  • Creating benchmarks for performance-critical Go code
  • Implementing fuzz tests or following TDD red-green-refactor cycle

Skip it if

  • Only relevant to Go projects, not other languages
  • Content is documentation/examples, not an automated tool

Facts

Repository
affaan-m/ECC
Status
Actively maintained
Last commit

Source preview

The instructions Claude Code reads when this skill runs.

# Patrones de Pruebas Go

Patrones completos de pruebas Go para escribir pruebas confiables y mantenibles siguiendo la metodología TDD.

## Cuándo Activar

- Escribir nuevas funciones o métodos Go
- Agregar cobertura de pruebas a código existente
- Crear benchmarks para código crítico en rendimiento
- Implementar pruebas fuzz para validación de entradas
- Seguir el flujo de trabajo TDD en proyectos Go

## Flujo de Trabajo TDD para Go

### El Ciclo RED-GREEN-REFACTOR

```
RED     → Escribir una prueba que falle primero
GREEN   → Escribir el código mínimo para pasar la prueba
REFACTOR → Mejorar el código manteniendo las pruebas en verde
REPEAT  → Continuar con el siguiente requisito
```

### TDD Paso a Paso en Go

```go
// Paso 1: Definir la interfaz/firma
// calculator.go
package calculator

func Add(a, b int) int {
    panic("not implemented") // Marcador de posición
}

// Paso 2: Escribir prueba que falle (RED)
// calculator_test.go
package calculator

import "testing"

func TestAdd(t *testing.T) {
    got := Add(2, 3)
    want := 5
    if got != want {
        t.Errorf("Add(2, 3) = %d; want %d", got, want)
    }
}

// Paso 3: Ejecutar prueba - verificar FALLO
// $ go test
// --- FAIL: TestAdd (0.00s)
// panic: not implemented

// Paso 4: Implementar código mínimo (GREEN)
func Add(a, b int) int {
    return a + b
}

// Paso 5: Ejecutar prueba - verificar PASA
// $ go test
// P
View full source on GitHub →

Other skills