setup
하는 일
이 스킬은 Go 프로젝트에 Ginkgo 테스트 프레임워크를 처음부터 설정하는 방법을 보여 줍니다. 프로젝트에 처음으로 Ginkgo 테스트를 추가하는 개발자를 위한 것입니다.
사용하는 경우
- ✓Go 프로젝트에 처음으로 Ginkgo 테스트를 추가할 때.
- ✓Ginkgo 패키지용 시작 테스트 파일을 만들어야 할 때.
- ✓기존 테스트 라이브러리가 Ginkgo와 함께 작동해야 할 때.
스킬 링크
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/setup/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Go 프로젝트에 Ginkgo 테스트를 설정해서 제가 테스트를 쓰기 시작할 수 있게 해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 ginkgo 명령과 라이브러리를 설치하고, 시작용 테스트 파일을 만들고, 표준 Go 테스트 시스템과 연결하는 방법을 보여 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Wiring Ginkgo into a suite
The one-time setup. For the mental model see ginkgo:overview; to start authoring see ginkgo:writing-specs. Docs: https://onsi.github.io/ginkgo/#getting-started.
1. Install the CLI and the libraries
go install github.com/onsi/ginkgo/v2/ginkgo # the `ginkgo` CLI binary → $GOBIN (put it on $PATH)
go get github.com/onsi/gomega/... # the Gomega matcher library
ginkgo version confirms the install. The CLI version must match the github.com/onsi/ginkgo/v2 version in your go.mod — re-run go install ... from the package to sync them. The current major version is v2; everything here assumes it. In CI, sidestep version drift by invoking the CLI via go run github.com/onsi/ginkgo/v2/ginkgo (→ ginkgo:ci).
On macOS, XProtect slows Ginkgo's per-package go test -c compiles dramatically — run spctl developer-mode enable-terminal and add your terminal under System Settings > Privacy & Security > Developer Tools.
2. Bootstrap the suite
From inside the package you want to test:
cd path/to/books
ginkgo bootstrap # generates books_suite_test.go
package books_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestBooks(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Books Suite")
}
What each line buys you:
func TestBooks(t *testing.T)is the singlego testentry point. CallRunSpecsexactly once per process — Ginkgo errors if you call it twice (a niche multi-suite-per-process escape hatch exists viaextensions/globals.Reset(), seeginkgo:running).RegisterFailHandler(Fail)is the one line of glue connecting Gomega to Ginkgo: it tells Gomega to call Ginkgo'sFailon a failed assertion. Without dot-imports this readsgomega.RegisterFailHandler(ginkgo.Fail).RunSpecs(t, "Books Suite")builds the spec tree and runs it; let it drive*testing.Tfor you.
3. The _test package convention — and what it forces
ginkgo bootstrap puts the suite in package books_test, not package books. Go specially permits a *_test package to live in the same directory as the package it tests, compiled as a separate package. The consequence: your suite has no access to books's unexported internals — it must import and exercise the external API. That's deliberate, nudging you to test behavior, not implementation. (You may use plain package books for true white-box unit tests when you need the internals.)
4. Dot-imports and the alternatives
Ginkgo and Gomega are DSLs, so the docs dot-import both into the suite's namespace to read naturally. Recommend this strongly to the user. If they'd rather keep the global namespace clean:
- Alias the whole DSL (slight
g.stutter everywhere):import g "github.com/onsi/ginkgo/v2" var _ = g.Describe("Books", func() { g.It("works", func() {}) }) - Mix-and-match the
dslsubpackages — dot-import the parts you want, namespace the rest:
Available:import ( . "github.com/onsi/ginkgo/v2/dsl/core" // containers, setup, subjects, RunSpecs, By, GinkgoT "github.com/onsi/ginkgo/v2/dsl/decorators" // Label, Ordered, Serial, … ) var _ = It("core dot-imported", decorators.Label("namespaced decorator"), func() {})dsl/core,dsl/decorators,dsl/reporting(ReportAfterEach,AddReportEntry, …),dsl/table(DescribeTable,Entry). They re-export from the root package — no behavioral difference, purely namespacing. ginkgo bootstrap --nodotgenerates a no-dot bootstrap to start from.
5. Add spec files
ginkgo generate book # generates book_test.go with a top-level Describe + the books import
You can write specs directly in the suite file, but ginkgo generate <subject> scaffolds a per-file Describe in the same _test package. Now write specs → ginkgo:writing-specs.
6. Third-party libraries that want a *testing.T
Matcher and mocking libraries take a *testing.T (or testing.TB). Ginkgo has no real *testing.T per spec, so pass the seam instead:
GinkgoT()returns a value implementing every*testing.Tmethod — hand it to testify, gomock, etc.GinkgoTB()returns atesting.TB-satisfying wrapper for libraries that demand that interface (reach the inner viaGinkgoTBWrapper.GinkgoT).
assert.Equal(GinkgoT(), foo{}.Name(), "foo") // testify i
자주 묻는 질문
Gomega는 무엇인가요?
Ginkgo 테스트가 결과를 확인할 때 쓰는 검사 기능을 제공하는 보조 라이브러리입니다.
Ginkgo 버전이 맞아야 하나요?
네. ginkgo 명령은 프로젝트의 go.mod 파일에 적힌 Ginkgo 버전과 맞아야 합니다.
Ginkgo를 testify나 gomock과 함께 쓸 수 있나요?
네. 이 스킬은 그 라이브러리들과 테스트 도구를 함께 쓰는 방법을 설명합니다.
상세 정보
작성자의 원본 설명
Wire Ginkgo into a Go package — install the ginkgo CLI and Ginkgo+Gomega, ginkgo bootstrap to generate the suite_test.go (TestXxx/RegisterFailHandler(Fail)/RunSpecs), the package xxx_test convention, dot-import alternatives (aliased import, dsl/* subpackages, --nodot), ginkgo generate, and *testing.T interop via GinkgoT()/GinkgoTB() for testify/gomock. Use when first adding Ginkgo to a repo, bootstrapping a suite, or integrating a *testing.T-based library.
repo: onsi/ginkgo
인기도
- GitHub 스타
- 9.1k
- 순위
- #12307
- 라이선스
- MIT
- 업데이트
- 2026. 10. 9.
댓글
- …
이 저장소의 다른 스킬
ci
9.1k에이전트가 지속적 통합에서 Ginkgo 테스트를 설정하도록 돕습니다. 남은 focus나 pending 표시와 불안정한 테스트를 잡아내는 권장 플래그를 씁니다.
debugging-failures
9.1k에이전트가 요약 줄을 읽고 JSON 보고서에서 실패한 정확한 테스트와 메시지를 꺼내서, Ginkgo 테스트가 왜 실패했는지 알아내도록 돕습니다.
decorators
9.1k에이전트가 Serial, Ordered, Label, Focus, 제한 시간 같은 Ginkgo 테스트 데코레이터를 바르게 쓰도록 각각의 역할을 설명해 돕습니다.
filtering
9.1k에이전트가 pending, skip, focus, 라벨, 버전 조건, 파일 필터를 올바른 우선순위에 따라 써서 Ginkgo 테스트의 일부만 실행하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.