overview
Fungsinya
Skill ini memberikan gambaran yang jelas tentang cara kerja alat tes Ginkgo untuk Go. Skill ini ditujukan untuk pengembang yang baru memulai proyek tes Ginkgo atau sedang merencanakan tugas pengujian.
Kapan dipakai
- โSaat Anda pertama kali bekerja dengan tes Ginkgo di proyek Go.
- โSaat Anda perlu memutuskan cara mendekati tugas pengujian di proyek Ginkgo.
- โSaat tes Ginkgo Anda berperilaku di luar dugaan.
Link skill
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/overview/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
โSaya baru mengenal Ginkgo untuk Go. Bisakah Anda menjelaskan cara tesnya diatur sebelum kita mulai?โ
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill menjelaskan bahwa Ginkgo lebih dulu membuat daftar semua tes lalu menjalankannya, dan menunjuk ke panduan lain untuk topik tertentu.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Ginkgo: the mental model
Ginkgo is an expressive BDD-style testing framework for Go, paired with the Gomega matcher library. You build suites out of nested container nodes (Describe/Context/When) and subject nodes (It), with setup nodes (BeforeEach/AfterEach/โฆ) supplying state. You drive it with the ginkgo CLI. Strongly prefer ginkgo over go test.
Read the canonical narrative docs at https://onsi.github.io/ginkgo/ โ they are the source of truth. This skill is the orientation; the other skills go deep.
The one idea: tree construction, then running
Ginkgo runs your suite in two distinct phases. Internalizing this explains nearly every Ginkgo gotcha:
- Tree-construction phase. Ginkgo invokes every container body exactly once to discover the structure of your suite. It collects โ but does not run โ the closures you pass to setup and subject nodes. The result is a tree it flattens into a list of specs.
- Run phase. Ginkgo walks the flattened spec list (randomized, possibly in parallel) and, for each spec, runs its setup closures, then its one subject closure, then its cleanup closures.
Container bodies run at construction time. Setup/subject closures run later, at run time. The consequences you must internalize:
- No assertions in container bodies. They'd run once during construction, with no spec active โ not as part of any test. Put assertions in
ItorBeforeEach. - No initialization in container bodies. A variable set in a
Describebody is set once, shared across every spec, and mutated by whichever spec runs first. Declare in the container, initialize inBeforeEachso every spec gets a pristine copy. โginkgo:writing-specs. - Loops that build specs run at construction time โ that's how you generate specs dynamically, but it also means closure-captured loop variables and any data the loop reads must be available then, not in
BeforeSuite. โginkgo:tables-and-dynamic-specs.
Spec independence โ the assumption everything rests on
Ginkgo assumes every spec is independent. This is what lets it randomize order (--randomize-all), run specs in parallel across processes (-p), and run any subset (--focus/labels). The rule that keeps you honest: declare in container, initialize in setup. Deliberate cross-spec dependencies break randomization and parallelism โ when you genuinely need ordering, say so explicitly with an Ordered container (โ ginkgo:ordering-and-flakes) rather than relying on definition order.
The Parallelism Model
Ginkgo's parallelism model is process-based: each process runs a subset of the specs, with no shared memory.
The node taxonomy at a glance
- Containers โ
Describe,Context,When(identical; pick the one that reads best). Organize the tree. - Subjects โ
It,Specify(identical). The actual test; contains the assertions. - Setup โ
BeforeEach/AfterEach(around every spec),JustBeforeEach/JustAfterEach(split configuration from creation),BeforeAll/AfterAll(once perOrderedcontainer),BeforeSuite/AfterSuite(once per suite),SynchronizedBeforeSuite/SynchronizedAfterSuite(for common setup, then per-process setup when parallel).DeferCleanupregisters teardown inline;DeferOnFailureregisters failure-only diagnostics that run before teardown. - Reporting โ
ReportAfterEach/ReportAfterSuiteetc. observe results. โginkgo:reporting. - Decorators โ modifiers attached to any node:
Serial,Ordered,Label,Focus,FlakeAttempts,SpecTimeout, โฆ โginkgo:decorators.
Failures work by panic: Fail (which Gomega calls for you) panics; Ginkgo recovers it, records the failure, and runs cleanup. A goroutine that might fail needs defer GinkgoRecover() or its panic crashes the suite. โ ginkgo:timeouts-and-async.
Where to go next
- Wiring Ginkgo into a project (bootstrap,
RunSpecs, the CLI, dot-import alternatives) โginkgo:setup - Authoring specs (containers, subjects, setup/cleanup, the construction-time pitfalls) โ
ginkgo:writing-specs - Table-driven and generated specs (
DescribeTable, shared behaviors) โginkgo:tables-and-dynamic-specs - Looking up a decorator โ
ginkgo:decorators - Running a subset (focus, skip, labels) โ
ginkgo:filtering - Running in parallel / integration suites โ
ginkgo:parallelism - **Ordered containers and fl
Pertanyaan umum
Apa itu Ginkgo?
Ginkgo adalah kerangka kerja tes untuk bahasa pemrograman Go yang memakai gaya penulisan yang mudah dibaca, mirip kalimat.
Apakah skill ini menulis tes untuk saya?
Skill memberikan latar belakang yang dibutuhkan untuk memandu penulisan tes, dan panduan lain dalam rangkaian yang sama membahas detailnya.
Apakah saya harus memakai perintah ginkgo?
Skill merekomendasikan alat baris perintah ginkgo dibanding perintah go test standar.
Detail
Deskripsi asli dari pembuat
The Ginkgo mental model for writing Go tests โ the one idea that explains everything (Ginkgo builds a spec tree at construction time, then runs it) and its consequences for how you write specs, plus spec independence and the node taxonomy. Use this first when you start working with Ginkgo in a project, or to decide how to approach a Ginkgo task. Routes to the other ginkgo:* skills.
repo: onsi/ginkgo
Popularitas
- Bintang GitHub
- 9.1k
- Peringkat
- #12303
- Lisensi
- MIT
- Diperbarui
- 9/10/2026
Komentar
- โฆ
Skill lain dari repositori ini
ci
9.1kMembantu agent Anda menyiapkan tes Ginkgo untuk integrasi berkelanjutan, dengan flag yang direkomendasikan untuk menangkap penanda fokus atau tertunda yang tertinggal serta tes yang tidak stabil.
debugging-failures
9.1kMembantu agent Anda mencari tahu mengapa tes Ginkgo gagal dengan membaca baris ringkasan dan mengambil tes yang gagal beserta pesannya dari laporan JSON.
decorators
9.1kMembantu agent Anda memakai dekorator tes Ginkgo dengan benar, seperti Serial, Ordered, Label, Focus, dan batas waktu, dengan menjelaskan fungsi masing-masing.
filtering
9.1kMembantu agent Anda menjalankan hanya sebagian tes Ginkgo, memakai pending, skip, focus, label, batasan versi, dan filter file sesuai urutan prioritasnya.
Skill serupa
test-driven-development
311kMengajari agent Anda menulis tes yang gagal dulu, melihatnya gagal, lalu menulis kode terkecil yang lulus, sebelum membangun fitur atau perbaikan apa pun.
verification-before-completion
311kMengajari agent Anda menjalankan pemeriksaan nyata dan membaca keluarannya sebelum menyatakan tugas, perbaikan, atau build sudah selesai atau lulus.
migrate-to-shoehorn
310kMengganti type cast berisiko di file tes Anda dengan pustaka shoehorn, sehingga tes bisa memakai data parsial dan tetap lulus pemeriksaan tipe.