Langsung ke konten
Skillpedia
Testing9.1k ยท #12303

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.md

Salin 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

Gunakan skill ini untuk membantu saya: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/overview/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

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:

  1. 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.
  2. 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 It or BeforeEach.
  • No initialization in container bodies. A variable set in a Describe body is set once, shared across every spec, and mutated by whichever spec runs first. Declare in the container, initialize in BeforeEach so 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 per Ordered container), BeforeSuite/AfterSuite (once per suite), SynchronizedBeforeSuite/SynchronizedAfterSuite (for common setup, then per-process setup when parallel). DeferCleanup registers teardown inline; DeferOnFailure registers failure-only diagnostics that run before teardown.
  • Reporting โ€” ReportAfterEach/ReportAfterSuite etc. 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

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa