Logo di Go Testing

Go Testing

Community
Integralist
go-testing

Write unit and integration tests for Go services. Use when creating, editing, or updating tests, test helpers, mocks, fuzz tests, or benchmarks in Go projects.

Panoramica

AutoreIntegralist
Repositoryagent-skills
Nome della skillgo-testing
Stelle
26
Fork
1
File inclusi
4
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 4 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da Integralist su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Go Testing in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/Integralist/agent-skills/tree/main/.agents/skills/go-testing
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Integralist/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/.agents/skills/go-testing .claude/skills/go-testing
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Go Testing in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Go Testing non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Go Testing non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Write Go tests test-first, with each case proving one behaviour through the package's public API. Load the conventions-go skill too: it sets style and linter rules for test code (testCases/tc, rr, noctx, scopeguard, comments, testify/mock), and wins where the two overlap. Before writing or changing tests, read TEST-CONTRACTS for assertion contracts. For acceptance suites, also load conventions-acceptance-tests: it owns scenario-to-code structure for Go/Godog and Make/Bash workflows.

Style. For unit tests, ask whether the user prefers table-driven (default) or f-tests (helper f in named subtests).

A test written before its types exist fails to compile, which doesn't count as red. So:

  1. Stub the types and signatures, returning zero values or a sentinel such as errors.New("unimplemented").
  2. Write the test against the stub and run go test; it must compile and fail on its assertion.
  3. Write the least code that passes, then tidy up and delete dead code.

What each test proves

  • One behaviour per case. The case name states it; a case proving two things becomes two cases.
  • Every error path. Each error the public API can return gets a case that checks the failure, matching errors with errors.Is or errors.AsType. Match on a substring only for an unexported third-party error.
  • Real assertions. Assert state changes, header values, or payloads, never only assert.NoError when the call returns values. Assert the fields that matter rather than whole structs with reflect.DeepEqual or cmp.Diff, which fail on timestamps and generated IDs.
  • Nothing unused. Deleting any field or setup step must break the test. Split cases with different setup into separate tables.
  • Distinct paths only. Each case covers its own branch or dimension, not a trivial variation of another. Add to an existing table before writing a new Test* function.
  • Cancellation. A long-running, I/O-bound, or goroutine-spawning function gets a test proving it stops promptly when ctx is cancelled.
  • Public API. Test through exported names, preferably from package foo_test. Reach each branch through the public call that triggers it; delete any branch no public path reaches. Extract logic to internal/ only when it is a module with its own interface and a second caller or adapter (see code-module-design), not just to make it testable.
  • No coverage loss. Refactoring tests must never lower package statement coverage (go test -cover).

Patterns

Testify mocks. When a test double embeds mock.Mock, call its methods through the embedded field—for example, m.Mock.Called(...) rather than m.Called(...). The explicit receiver makes the mock dependency visible.

Table-driven:

go
// TestNormalize proves Normalize upper-cases input and rejects empty
// strings with ErrEmptyInput.
func TestNormalize(t *testing.T) {
	testCases := []struct {
		// name states the behaviour this case proves.
		name string
		// input is passed to Normalize.
		input string
		// expected is the result on success.
		expected string
		// wantErr is the sentinel to match with errors.Is, or nil.
		wantErr error
	}{
		{name: "upper-cases valid input", input: "hello", expected: "HELLO"},
		{name: "rejects empty input", input: "", wantErr: ErrEmptyInput},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			result, err := Normalize(tc.input)
			if tc.wantErr != nil {
				if !errors.Is(err, tc.wantErr) {
					t.Fatalf("expected %v, got %v", tc.wantErr, err)
				}
				return
			}
			if err != nil {
				t.Fatalf("unexpected error: %v", err)
			}
			if result != tc.expected {
				t.Errorf("expected %q, got %q", tc.expected, result)
			}
		})
	}
}

When cases prove one invariant across operations with different signatures, give each case an invoke func(*Repository) error closure rather than reaching for generics.

F-test:

go
// TestShout proves Shout upper-cases its input.
func TestShout(t *testing.T) {
	// f checks one input against its expected output.
	f := func(t *testing.T, input, expected string) {
		t.Helper()
		if got := Shout(input); got != expected {
			t.Fatalf("Shout(%q) = %q; want %q", input, got, expected)
		}
	}

	t.Run("converts to uppercase", func(t *testing.T) { f(t, "hello", "HELLO") })
	t.Run("handles empty string", func(t *testing.T) { f(t, "", "") })
}

Helpers and context. Call t.Helper() in every helper. Pass t.Context() (Go 1.24+), not context.Background(), to code under test; it cancels when the test ends. Don't block on a bare <-t.Context().Done() for an async wait, or a stuck test hangs until the suite times out; bound it:

go
ctx, cancel := context.WithTimeout(t.Context(), time.Second)
defer cancel()

select {
case <-renewed:
case <-ctx.Done():
	t.Fatalf("claim was not renewed: %v", ctx.Err())
}

Assertions. Prefer t.Errorf and t.Fatalf; use testify/assert for complex checks.

Running and references

bash
make test                                    # unit tests
make test-integration                        # integration tests
go test -v -run TestName ./pkg/...           # one test
go test -race ./...                          # race detector
go test -cover ./...                         # coverage

For specialised work, read:

  • INTEGRATION.md: e2e tests under the e2e build tag.
  • ACCEPTANCE.md: a runnable Godog wiring example for the canonical living features.
  • FUZZ-AND-BENCHMARKS.md: testing.F fuzzing and b.Loop() benchmarks.
  • COVERAGE-PRUNING.md: finding and pruning overlapping tests with Tobari.
  • The mutation-testing skill: checking whether tests catch behaviour changes.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Go Testing?

Write unit and integration tests for Go services. Use when creating, editing, or updating tests, test helpers, mocks, fuzz tests, or benchmarks in Go projects.

Perché usare Go Testing su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Go Testing è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Go Testing in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/Integralist/agent-skills/tree/main/.agents/skills/go-testing. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Go Testing?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Go Testing?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Go Testing: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Go Testing è gratuita?

È pubblicata su GitHub da Integralist. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇