ordering-and-flakes
Fungsinya
Skill ini menjelaskan cara menjalankan tes Ginkgo dalam urutan tetap dan cara mengelola tes yang kadang gagal. Skill ini ditujukan untuk pengembang yang menulis tes Go dengan kerangka kerja Ginkgo.
Kapan dipakai
- βSaat sekumpulan tes Go harus berjalan dalam urutan tetap.
- βSaat tes Ginkgo hanya gagal sebagian waktu dan perlu diperiksa atau dicoba ulang.
- βSaat Anda ingin menemukan tes yang bergantung pada urutan eksekusinya.
Link skill
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ordering-and-flakes/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
βTes Go kami gagal secara acak. Bisakah Anda membuat tes yang tidak stabil itu berjalan andal di Ginkgo?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill menunjukkan pengaturan Ginkgo mana yang memaksa tes berjalan satu per satu, dan pengaturan mana yang mengulang atau mencoba ulang tes untuk memunculkan perilaku yang tidak stabil.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Ordering and flakes
Two topics that share a root cause: specs that aren't truly independent (ginkgo:overview). Ordering decorators let you declare a dependency on purpose; flake controls let you manage or expose one. Docs: https://onsi.github.io/ginkgo/#serial-specs, https://onsi.github.io/ginkgo/#ordered-containers, https://onsi.github.io/ginkgo/#repeating-spec-runs-and-managing-flaky-specs.
Serial: opt out of parallelism
Serial (container or subject) guarantees a spec never runs in parallel with anything else. Under the hood Ginkgo runs serial specs last, on process #1, after every other process has finished its suite. Reach for it sparingly. OK for benchmarks, resource hogs, or specs that put an external resource into a known-bad state - but not OK as a band-aid for order-dependence or poorly isolated code/specs.
Describe("Something expensive", Serial, func() {
It("is a resource hog that can't share the box", func() { ... })
})
β ginkgo:decorators, ginkgo:parallelism.
Ordered: run specs in definition order
Ordered (container only) guarantees its child specs run sequentially, in written order, on one process β so they may legitimately mutate shared closure state. They can still parallelize against specs in other containers; only the inner order is pinned.
Describe("checking out a book", Ordered, func() {
var libraryClient *library.Client
var book *books.Book
BeforeAll(func() { // once, before the first spec
libraryClient = library.NewClient()
Expect(libraryClient.Connect()).To(Succeed())
DeferCleanup(libraryClient.Disconnect) // context-aware: behaves like AfterAll
DeferOnFailure(libraryClient.DumpState) // covers EVERY spec in this container; runs before teardown
})
It("can fetch a book", func() { book, _ = libraryClient.FetchByTitle("Les Miserables") })
It("can check it out", func() { Expect(library.CheckOut(book)).To(Succeed()) })
It("is then out of stock", func() { ... })
AfterAll(func() { ... }) // once, after the last spec
})
BeforeAll/AfterAllare legal only inside anOrderedcontainer (or a container nested within one). That's the whole point ofOrderedβ once-per-group expensive setup.- A failing spec skips the rest of the group by default (then
AfterAllstill runs). Spec independence is gone, so Ginkgo won't pretend the later specs are meaningful. ContinueOnFailure(outermostOrderedonly β error on a nested container) overrides that: keep running later specs after a failure. Use it whenOrderedis just shared setup, not a dependent flow. A failedBeforeAllstill skips everything β the setup is presumed broken.- Nested containers inside an
Orderedcontainer are automaticallyOrdered; there's no way to un-order them.
OncePerOrdered: outer *Each setup that respects groups
A top-level BeforeEach that resets state runs before every spec β which breaks an Ordered group's first-spec-sets-up-rest contract (spec 1 passes, the rest get wiped). Decorate it with OncePerOrdered so it runs once per independent unit: still per-spec for normal specs, but once around each Ordered container (like a BeforeAll).
BeforeEach(OncePerOrdered, func() {
libraryClient = library.NewClient()
snapshot := libraryClient.TakeSnapshot()
DeferCleanup(libraryClient.RestoreSnapshot, snapshot)
})
Applies to BeforeEach/JustBeforeEach/AfterEach/JustAfterEach only β not ReportBeforeEach/ReportAfterEach (reporting is always per-spec).
The Serial-inside-Ordered gotcha
You cannot mark an individual spec inside an Ordered container Serial. To make a whole ordered group run serially, put both decorators on the container: Describe("...", Ordered, Serial, func(){...}).
Ordered vs one big It
Ordered and a single It with By steps (ginkgo:writing-specs) solve the same "dependent flow" problem. Prefer one It + By by default β it stays fully parallelizable and independent. Reach for Ordered when you want each step reported as its own spec, or genuinely need BeforeAll once-per-group setup. Either way, use Ordered only when needed β it gives up internal parallelism.
SpecPriority
SpecPriority(int) (default 0, higher runs earlier, may be negative) is a scheduling hint β e.g. "boulders first, then sand" in big suites. Honored per-spec under --randomize-all, otherwise per outermost
Pertanyaan umum
Apakah ini mengubah kecepatan tes saya?
Menjalankan tes dalam urutan tetap atau satu per satu bisa membuatnya lebih lambat, karena tidak bisa berjalan bersamaan.
Apakah saya perlu tahu Go untuk memakai ini?
Ya, skill ini membahas tes Go, jadi Anda memerlukan proyek Go yang memakai Ginkgo.
Apakah ini bisa membantu menemukan tes yang saling bergantung?
Bisa. Skill menjelaskan cara mengulang proses dan memeriksa ketergantungan urutan pada tes.
Detail
Deskripsi asli dari pembuat
Control spec ordering and manage flaky specs β Serial, Ordered containers with BeforeAll/AfterAll/ContinueOnFailure, OncePerOrdered, SpecPriority, plus FlakeAttempts/--flake-attempts, MustPassRepeatedly, --repeat, and --until-it-fails. Use when specs must run in a fixed order, you need once-per-group setup, you're combining Serial+Ordered, a spec is flaky, or you want to hunt order-dependence with --until-it-fails -p --randomize-all.
repo: onsi/ginkgo
Popularitas
- Bintang GitHub
- 9.1k
- Peringkat
- #12302
- 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.