मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग9.1k · #12302

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ordering-and-flakes/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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/AfterAll are legal only inside an Ordered container (or a container nested within one). That's the whole point of Ordered — once-per-group expensive setup.
  • A failing spec skips the rest of the group by default (then AfterAll still runs). Spec independence is gone, so Ginkgo won't pretend the later specs are meaningful.
  • ContinueOnFailure (outermost Ordered only — error on a nested container) overrides that: keep running later specs after a failure. Use it when Ordered is just shared setup, not a dependent flow. A failed BeforeAll still skips everything — the setup is presumed broken.
  • Nested containers inside an Ordered container are automatically Ordered; 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

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills