ordering-and-flakes
यह क्या करती है
यह स्किल बताती है कि Ginkgo टेस्ट तय क्रम में कैसे चलाएं और कभी-कभी फ़ेल होने वाले टेस्ट कैसे संभालें। यह उन डेवलपर्स के लिए है जो Ginkgo फ़्रेमवर्क से Go टेस्ट लिखते हैं।
कब इस्तेमाल करें
- ✓जब Go टेस्ट के एक समूह को तय क्रम में चलना हो।
- ✓जब कोई Ginkgo टेस्ट केवल कभी-कभी फ़ेल होता हो और उसे जांचना या दोबारा चलाना हो।
- ✓जब आप यह पता करना चाहते हों कि कौन से टेस्ट चलने के क्रम पर निर्भर हैं।
Skill का लिंक
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ordering-and-flakes/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“हमारे Go टेस्ट बेतरतीब ढंग से फ़ेल होते हैं, क्या आप Ginkgo में flaky टेस्ट को भरोसेमंद ढंग से चलने लायक बना सकते हैं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह दिखाती है कि कौन सी Ginkgo सेटिंग टेस्ट को एक के बाद एक चलाने पर मजबूर करती है, और कौन सी सेटिंग flaky व्यवहार उजागर करने के लिए टेस्ट को दोहराती या retry करती है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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
अक्सर पूछे जाने वाले सवाल
क्या इससे टेस्ट की रफ़्तार बदलती है?
तय क्रम में या एक-एक करके चलाने से टेस्ट धीमे हो सकते हैं, क्योंकि वे एक साथ नहीं चल पाते।
क्या इसे इस्तेमाल करने के लिए Go जानना ज़रूरी है?
हाँ, यह स्किल Go टेस्ट के बारे में है, इसलिए आपके पास Ginkgo इस्तेमाल करने वाला Go प्रोजेक्ट होना चाहिए।
क्या यह ऐसे टेस्ट खोजने में मदद करती है जो एक-दूसरे पर निर्भर हैं?
हाँ, यह बताती है कि रन दोहराकर क्रम पर निर्भरता कैसे जांची जाए।
जानकारी
लेखक का मूल विवरण
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
लोकप्रियता
- GitHub स्टार
- 9.1k
- रैंकिंग में स्थान
- #12302
- लाइसेंस
- MIT
- अपडेट की गई
- 9/10/2026
कमेंट
- …
इस repository की और skills
ci
9.1kयह आपके एजेंट को Ginkgo टेस्ट CI के लिए सेट करने में मदद करती है, ताकि बचे हुए focus या pending निशान और flaky टेस्ट पकड़े जा सकें।
debugging-failures
9.1kयह आपके एजेंट को summary लाइन पढ़कर और JSON रिपोर्ट से ठीक फ़ेल होने वाले टेस्ट और संदेश निकालकर Ginkgo टेस्ट फ़ेल होने का कारण ढूंढने में मदद करती है।
decorators
9.1kयह आपके एजेंट को Ginkgo टेस्ट decorators सही ढंग से इस्तेमाल करने में मदद करती है, जैसे Serial, Ordered, Label, Focus और timeouts, हर एक का काम समझाकर।
filtering
9.1kयह आपके एजेंट को Ginkgo के कुछ ही टेस्ट चलाने में मदद करती है, pending, skip, focus, labels और file filters को सही क्रम में लगाकर।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।