ordering-and-flakes
하는 일
이 스킬은 Go 테스트를 고정된 순서로 실행하는 방법과, 때때로 실패하는 테스트를 관리하는 방법을 설명합니다. Ginkgo 프레임워크로 Go 테스트를 작성하는 개발자를 위한 것입니다.
사용하는 경우
- ✓Go 테스트 묶음을 고정된 순서로 실행해야 할 때.
- ✓Ginkgo 테스트가 가끔만 실패해서 확인하거나 재시도해야 할 때.
- ✓실행 순서에 따라 결과가 달라지는 테스트를 찾고 싶을 때.
스킬 링크
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/ordering-and-flakes/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 Go 테스트가 무작위로 실패합니다. Ginkgo에서 불안정한 테스트가 안정적으로 실행되도록 고쳐 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 어떤 Ginkgo 설정이 테스트를 하나씩 순서대로 실행하게 만드는지, 그리고 어떤 설정이 테스트를 반복하거나 재시도해서 불안정한 동작을 드러내는지 보여 줍니다.
기술 내용 (원본 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
- 업데이트
- 2026. 10. 9.
댓글
- …
이 저장소의 다른 스킬
ci
9.1k에이전트가 지속적 통합에서 Ginkgo 테스트를 설정하도록 돕습니다. 남은 focus나 pending 표시와 불안정한 테스트를 잡아내는 권장 플래그를 씁니다.
debugging-failures
9.1k에이전트가 요약 줄을 읽고 JSON 보고서에서 실패한 정확한 테스트와 메시지를 꺼내서, Ginkgo 테스트가 왜 실패했는지 알아내도록 돕습니다.
decorators
9.1k에이전트가 Serial, Ordered, Label, Focus, 제한 시간 같은 Ginkgo 테스트 데코레이터를 바르게 쓰도록 각각의 역할을 설명해 돕습니다.
filtering
9.1k에이전트가 pending, skip, focus, 라벨, 버전 조건, 파일 필터를 올바른 우선순위에 따라 써서 Ginkgo 테스트의 일부만 실행하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.