Chuyển đến nội dung
Skillpedia
Kiểm thử9.1k · #12306

running

Skill này làm gì

Skill này giải thích cách khởi chạy các bài kiểm thử Ginkgo từ dòng lệnh và nên dùng tùy chọn nào. Nó dành cho lập trình viên chạy kiểm thử Go bằng công cụ Ginkgo.

Khi nào nên dùng

  • ✓Khi bạn cần chạy một hoặc nhiều bộ kiểm thử Ginkgo từ terminal.
  • ✓Khi bạn muốn xem trước các bài kiểm thử sẽ chạy mà không thực sự chạy chúng.
  • ✓Khi bạn muốn chạy kiểm thử theo thứ tự ngẫu nhiên hoặc lặp lại để tìm lỗi.

Liên kết skill

https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/running/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/running/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để chạy tất cả các bài kiểm thử Ginkgo trong dự án Go của tôi và xem bài nào sẽ chạy đầu tiên?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill liệt kê các lệnh và tùy chọn của ginkgo, như chạy một thư mục kiểm thử, xem trước danh sách, hoặc theo dõi thay đổi file.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Running Ginkgo

How to drive the suite once it's wired up (ginkgo:setup). For a production CI configuration, see ginkgo:ci. Docs: https://onsi.github.io/ginkgo/#ginkgo-cli-overview.

The CLI surface

ginkgo is the recommended runner — you can run suites with go test, but only the CLI does parallelism and profile aggregation, and a few go test flags (e.g. -count=N, use --repeat=N) are unsupported. ginkgo is shorthand for ginkgo run; it passes through nearly all go test/go build flags.

ginkgo                                  # run the suite in the current directory
ginkgo path/to/suite path/to/other      # run several named suites
ginkgo -r                               # recurse the tree, run every suite found (== ginkgo ./...)
ginkgo -p                               # run in parallel (→ ginkgo:parallelism)
ginkgo -v --dry-run                     # build the tree and print what WOULD run, without running
ginkgo <GINKGO-FLAGS> <PACKAGES> -- <PASS-THROUGHS>   # the full grammar

Ginkgo flags must come before the package list; suite-bound args go after --. Subcommands:

Command Does
ginkgo build path/... Precompile each suite to a package.test binary (accepts a subset of run flags — compile-time only)
ginkgo watch -r -p Re-run suites when they or their dependencies change (-depth tunes dependency monitoring)
ginkgo bootstrap / ginkgo generate <subject> Scaffold a suite / a spec file (→ ginkgo:setup); both take --template/--template-data
ginkgo outline <file> Static (AST-parsed) spec outline as csv/indent/json — no compile needed
ginkgo unfocus Strip all programmatic F-focus from the tree (→ ginkgo:filtering)
ginkgo labels List the Labels used in a suite (naive parse)
ginkgo version Print the CLI version

Precompiled binaries run via ginkgo package.test or ./package.test — but to run a precompiled suite in parallel you must go back through the CLI: ginkgo -p ./package.test. Cross-compile with the usual GOOS/GOARCH.

Randomization

Ginkgo randomizes spec order to surface spec pollution. By default it only shuffles top-level containers (specs within a container keep file order, easing debugging).

  • --randomize-all — shuffle every spec. Use it in CI (→ ginkgo:ci).
  • --randomize-suites — shuffle the order suites run in (multi-suite runs).
  • --seed=N — pin the seed (printed near the top of every run) to reproduce a failing order exactly. Specs that generate randomness should seed off GinkgoRandomSeed() so the seed fully determines the run.

Randomization is only sound because Ginkgo assumes specs are independent (→ ginkgo:overview); when ordering is genuinely required, use an Ordered container (→ ginkgo:ordering-and-flakes), never definition order.

Running multiple suites

With -r or multiple package args, Ginkgo compiles suites in parallel but always runs them sequentially.

  • --compilers=N — number of parallel compile workers (default: one per core).
  • --skip-package=a,b,c — comma-separated; skips any suite whose path contains a listed substring (not compiled, not run).
  • --keep-going — run all suites even after one fails (default stops after the first failed suite), to collect every failure. (--fail-fast controls stopping within a suite.)

You can also run several suites within one process by calling RunSpecs more than once, resetting Ginkgo's global state between calls with extensions/globals.Reset() (a niche orchestration escape hatch — your package-level state is not reset, only Ginkgo's).

Previewing specs

  • ginkgo --dry-run -v compiles, builds the tree, and walks it honoring filters and dynamically generated specs — the most complete preview. --dry-run can't combine with -p/--procs; it runs in series. (ginkgo outline is faster but static, so it misses dynamic specs and filter/order effects.)
  • PreviewSpecs in place of RunSpecs returns a full Report (run specs → SpecStatePassed, skipped → SpecStateSkipped) for programmatic inspection. Pass it the same description+decorators you'd give RunSpecs:
    func TestMySuite(t *testing.T) {
        if config, _ := GinkgoConfiguration(); config.DryRun {
            report := PreviewSpecs("My Suite", Label("suite-label"))
            _ = report // e.g. reporters.GenerateJUnitReport(report, "./preview.xml")
        } else {
    
Câu hỏi thường gặp

Tôi có thể dùng go test thay thế không?

Được, nhưng lệnh ginkgo hỗ trợ các tính năng như chạy song song mà go test không có.

Làm sao để truyền cài đặt cho các bài kiểm thử của tôi?

Skill giải thích rằng các tùy chọn đặt sau dấu gạch ngang kép sẽ được gửi thẳng đến chương trình kiểm thử.

Chế độ theo dõi làm gì?

Nó tự động chạy lại các bài kiểm thử khi file thay đổi.

Chi tiết

Mô tả gốc của tác giả

Run Ginkgo suites with the ginkgo CLI — run, -r, -p, --dry-run, watch, build (precompiled .test binaries), generate, outline, unfocus, labels, version; spec randomization (--randomize-all/--randomize-suites/--seed); running multiple suites (--keep-going/--skip-package/--compilers); previewing (--dry-run, PreviewSpecs); and parameterizing a suite via env vars or init()-registered flags after -- plus GinkgoConfiguration() overrides. Use when running suites locally, precompiling, watching for changes, or parameterizing a run from the command line. For a CI configuration see ginkgo:ci.

repo: onsi/ginkgo

Độ phổ biến

Sao GitHub
9.1k
Vị trí xếp hạng
#12306
Giấy phép
MIT
Cập nhật
9/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự