Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsMay 15, 2026·3 min de lectura

Ginkgo — BDD Testing Framework for Go

An expressive BDD-style testing framework for Go with support for spec nesting, lifecycle hooks, parallel execution, and structured test output. Pairs with the Gomega matcher library.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Ginkgo Overview
Comando de instalación directa
npx -y tokrepo@latest install f82958bc-5036-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Ginkgo is a testing framework for Go that uses Describe/Context/It blocks to organize tests in a behavior-driven style. It integrates with Go's native testing infrastructure while adding features like ordered and parallel specs, lifecycle hooks, and rich reporting. Gomega, its companion matcher library, provides fluent assertions.

What Ginkgo Does

  • Structures tests using nested Describe, Context, and It blocks
  • Runs specs in parallel across multiple processes with automatic output isolation
  • Provides BeforeEach, AfterEach, BeforeSuite, and AfterSuite lifecycle hooks
  • Generates JUnit, JSON, and custom-format test reports
  • Integrates with go test so CI pipelines need no special tooling

Architecture Overview

Ginkgo builds a spec tree at init time by executing the closure-based DSL. The runner then walks the tree, executing each leaf It node with its accumulated BeforeEach chain. Parallel mode forks multiple go test processes, each running a subset of specs, with a central process collecting results. Gomega assertions hook into Ginkgo's failure reporting to produce clear output on mismatch.

Setup & Configuration

  • Install the CLI with go install github.com/onsi/ginkgo/v2/ginkgo@latest
  • Bootstrap a suite with ginkgo bootstrap in any package directory
  • Generate spec files with ginkgo generate <name>
  • Configure parallelism with ginkgo -p or ginkgo --procs=N
  • Add labels and decorators for filtering: It("works", Label("integration"), func() { ... })

Key Features

  • Spec decorators: Serial, Ordered, FlakeAttempts, and custom Labels
  • Built-in support for table-driven specs via DescribeTable and Entry
  • Progress reporting shows which spec is currently running in long suites
  • Interruption handling cleans up resources on timeout or SIGINT
  • Watch mode re-runs affected specs when source files change

Comparison with Similar Tools

  • testing (stdlib) — simpler, no dependencies, but lacks nesting, lifecycle hooks, and parallel isolation
  • Testify — adds assertions and mocks to stdlib tests; less structured than BDD-style specs
  • GoConvey — BDD with a browser UI; Ginkgo offers stronger parallel execution and reporting
  • go-check — older BDD-like framework; Ginkgo has a more active community and richer feature set

FAQ

Q: Does Ginkgo work with go test? A: Yes. Ginkgo specs compile as standard Go tests. Running go test works, though the ginkgo CLI adds parallelism and reporting features.

Q: How do I run only specific specs? A: Use ginkgo --focus="pattern" to match spec text, or ginkgo --label-filter="integration" to filter by label.

Q: Can I mix Ginkgo specs with regular Go tests? A: Yes. Standard Test functions coexist in the same package and run alongside Ginkgo specs.

Q: Is Gomega required? A: No. You can use any assertion library or bare t.Fatal calls, but Gomega's matchers integrate tightly with Ginkgo's failure reporting.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados