overview
ما الذي تفعله
تعطي هذه المهارة صورة واضحة لطريقة عمل أداة Ginkgo للاختبار في Go. وهي مناسبة للمطورين الذين يبدؤون مشروع اختبار Ginkgo أو يخططون لمهمة اختبار.
متى تستخدمها
- ✓عندما تبدأ العمل على اختبارات Ginkgo في مشروع Go لأول مرة.
- ✓عندما تحتاج إلى تحديد طريقة التعامل مع مهمة اختبار في مشروع Ginkgo.
- ✓عندما تتصرف اختبارات Ginkgo بطريقة لم تتوقعها.
رابط المهارة
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/overview/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أنا جديد على Ginkgo لـ Go، هل تشرح لي كيف تُنظَّم اختباراته قبل أن نبدأ؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تشرح المهارة أن Ginkgo يبني أولاً قائمة بكل الاختبارات ثم يشغّلها، وتشير إلى أدلة أخرى لمواضيع محددة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من 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:
- 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.
- 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
ItorBeforeEach. - No initialization in container bodies. A variable set in a
Describebody is set once, shared across every spec, and mutated by whichever spec runs first. Declare in the container, initialize inBeforeEachso 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 perOrderedcontainer),BeforeSuite/AfterSuite(once per suite),SynchronizedBeforeSuite/SynchronizedAfterSuite(for common setup, then per-process setup when parallel).DeferCleanupregisters teardown inline;DeferOnFailureregisters failure-only diagnostics that run before teardown. - Reporting —
ReportAfterEach/ReportAfterSuiteetc. 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
الأسئلة الشائعة
ما Ginkgo؟
Ginkgo إطار اختبار للغة Go يعتمد على أسلوب قريب من الجمل المقروءة.
هل تكتب هذه المهارة الاختبارات عني؟
تعطي الخلفية اللازمة لتوجيه كتابة الاختبارات، وتغطي أدلة أخرى في المجموعة نفسها التفاصيل.
هل يجب أن أستخدم أمر ginkgo؟
تنصح المهارة بأداة سطر الأوامر ginkgo بدلاً من أمر go test القياسي.
التفاصيل
الوصف الأصلي من المؤلف
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
الشعبية
- نجوم GitHub
- 9.1k
- الترتيب
- #12303
- الترخيص
- MIT
- آخر تحديث
- 9/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
ci
9.1kيساعد وكيلك على إعداد اختبارات Ginkgo في التكامل المستمر، بخيارات موصى بها تكشف علامات التركيز والتعليق المنسية.
debugging-failures
9.1kيساعد وكيلك على معرفة سبب فشل اختبارات Ginkgo، بقراءة سطر النتيجة وسحب الاختبارات الفاشلة ورسائلها بدقة من تقرير JSON.
decorators
9.1kيساعد وكيلك على استخدام مزخرفات اختبارات Ginkgo بشكل صحيح، مثل Serial وOrdered وLabel وFocus والمهلات الزمنية، بشرح وظيفة كل واحدة.
filtering
9.1kيساعد وكيلك على تشغيل جزء فقط من اختبارات Ginkgo، باستخدام التعليق والتخطي والتركيز والتسميات والفلاتر بالترتيب الصحيح.
مهارات مشابهة
test-driven-development
311kيعلّم وكيلك كتابة اختبار فاشل أولًا، ثم رؤيته يفشل، ثم كتابة أصغر شيفرة تنجحه، قبل بناء أي ميزة أو إصلاح.
verification-before-completion
311kيعلّم وكيلك تشغيل فحوصات حقيقية وقراءة نتائجها قبل أن يقول إن المهمة أو الإصلاح أو البناء مكتمل أو ناجح.
migrate-to-shoehorn
310kيستبدل تأكيدات النوع الخطرة في ملفات الاختبار بمكتبة shoehorn، حتى تتمكن الاختبارات من استخدام بيانات جزئية وتجتاز فحوص الأنواع.