Agent skill
ginkgo-gomega
Ginkgo v2 BDD testing framework and Gomega assertions (Go)
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ginkgo-gomega
SKILL.md
Skill: ginkgo-gomega
What I do
I teach Ginkgo v2 BDD testing framework for Go, using descriptive test suites with human-readable assertions via Gomega. This makes tests readable as specifications while maintaining rigorous test coverage.
When to use me
- Writing BDD tests in Go
- Converting table-driven tests to Ginkgo format
- Building test suites with nested Describe/Context blocks
- Writing expressive assertions with Gomega matchers
- Implementing hierarchical test organisation
Core principles
- Tests are specifications - Test names describe behaviour, not implementation
- Describe/Context nesting - Organise tests by context, not flat
- Expressive matchers - Assertions read like English, not assertions
- BeforeEach/AfterEach - Setup/teardown grouped with tests
- Table-driven as last resort - Ginkgo specs usually clearer
Patterns & examples
Ginkgo test structure:
Describe("User authentication", func() {
var user *User
BeforeEach(func() {
user = NewUser("[email protected]")
})
Context("valid credentials", func() {
It("authenticates successfully", func() {
err := user.Authenticate("password123")
Expect(err).NotTo(HaveOccurred())
Expect(user.IsAuthenticated).To(BeTrue())
})
})
Context("invalid credentials", func() {
It("returns authentication error", func() {
err := user.Authenticate("wrongpass")
Expect(err).To(HaveOccurred())
Expect(user.IsAuthenticated).To(BeFalse())
})
})
})
Gomega matchers (expressive):
// ✅ Correct: readable matcher chains
Expect(users).To(HaveLen(3))
Expect(name).To(Equal("Alice"))
Expect(age).To(BeNumerically(">", 18))
Expect(tags).To(ContainElement("featured"))
Expect(response).To(HaveKeyWithValue("status", "success"))
// ❌ Wrong: non-matcher assertions
if len(users) != 3 { t.Fail() }
if name != "Alice" { t.Fail() }
Async testing pattern:
It("processes message eventually", func(done Done) {
result := make(chan string)
go ProcessAsync(result)
// Gomega Eventually waits for condition
Eventually(result).Should(Receive(Equal("done")))
close(done)
}, 2.0) // 2 second timeout
Anti-patterns to avoid
- ❌ Flat test list (use Describe/Context nesting)
- ❌ Multiple assertions in one It (focus on one behaviour)
- ❌ Magic values in tests (use meaningful variable names)
- ❌ Table-driven when Ginkgo specs would be clearer
- ❌ Ignoring helper functions (extract test setup)
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Testing-BDD/Ginkgo Gomega.md
Related skills
bdd-workflow- Red-Green-Refactor cycle that Ginkgo enablesgolang- Core Go language idiomstest-fixtures-go- Generate realistic test data for Ginkgo specsgomock- Mocking in Ginkgo testsclean-code- Apply SOLID principles to test code
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?