golang-testing
OfficialPatrones 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.
What this skill does
When applied, it prepends a system prompt before your request is sent — no extra calls and no change to how you are billed beyond the added tokens.
---
name: golang-testing
description: 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.
origin: ECC
---
# 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
// PASS
// Paso 6: Refactorizar si es necesario, verificar que las pruebas sigan pasando
```
## Pruebas Basadas en Tablas
El patrón estándar para pruebas Go. Permite cobertura comprensiva con código mínimo.
```go
func TestAdd(t *testing.T) {
tests := []struct {
name string
a, b int
expected int
}{
{"positive numbers", 2, Use this skill
Add a "skill" field with the skill’s ID to your chat completion request. It is applied server-side before your prompt is sent — no extra calls.
{
"model": "gpt-4o-mini",
"skill": "imp-76a55cfb-aa1d-4f4c-b299-90d97ed71265",
"messages": [{ "role": "user", "content": "…" }]
}Install the skill, enable it in your dashboard and (optionally) limit it to specific models. It then applies automatically to every matching request — with no "skill" field to send each time.
Set it up in your dashboardMore skills
Delegate coding work to Codex, Claude Code, or OpenCode as background workers; not simple edits or read-only code lookup.
Create, edit, audit, tidy, validate, or restructure AgentSkills and SKILL.md files.
Search and analyze your own session logs (older/parent conversations) using jq.
Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.
Diagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.
List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.
Create, search, and manage Bear notes via grizzly CLI.