bdd-anti-patterns
Skill5 starsChanged 6 months agoMITView on GitHub
When the user wants to audit, refactor, or rescue a Cucumber / Gherkin / SpecFlow / Reqnroll / behave BDD suite from common failure modes. Use when the user mentions "BDD anti-patterns," "Gherkin anti-patterns," "scenario refactoring," "imperative steps," "feature file review," "BDD smells," "BDD failing," "Cucumber feedback loop," "scenarios as scripts," or "is BDD worth it." For Cucumber/Gherkin basics see cucumber-gherkin. For .NET BDD see specflow-reqnroll. For Python BDD see behave.
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- qa-engineering-suiteSkill
- accessibility-testingSkill
- ai-augmented-testingSkill
- appiumSkill
- artillerySkill
- behaveSkill
- chaos-engineeringSkill
- ci-test-orchestrationSkill
- cloud-test-gridsSkill
- code-coverageSkill
- cucumber-gherkinSkill
- cypressSkill
- detoxSkill
- espressoSkill
- feature-flag-testingSkill
- flaky-test-managementSkill
- gatlingSkill
- go-testSkill
- graphql-testingSkill
- grpc-testingSkill
- jest-vitestSkill
- jmeterSkill
- junit-testngSkill
- k6Skill
- karateSkill
- llm-eval-testingSkill
- locustSkill
- maestroSkill
- mutation-testingSkill
- pact-contract-testingSkill
- playwrightSkill
- postman-newmanSkill
- production-testingSkill
- puppeteerSkill
- pytest-apiSkill
- pytestSkill
- qa-contextSkill
- rest-assuredSkill
- rspecSkill
- security-testingSkill
- selenium-gridSkill
- seleniumSkill
- specflow-reqnrollSkill
- supertestSkill
- testcafeSkill
- testcontainersSkill
- test-data-managementSkill
- test-design-techniquesSkill
- test-environment-managementSkill
- test-reportingSkill
- test-strategySkill
- visual-regressionSkill
- webdriverioSkill
- wiremockSkill
- xcuitestSkill
- xunit-nunitSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 11 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 14
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering.
- Distinctive: line 22
If the file does not exist, ask: who authors, who reads, how big the suite is, and what specific pain they're feeling.
- Very specific: line 105
Fix: every Then asserts something specific and meaningful.
- Distinctive: line 121
Fix: write this as a plain xUnit / pytest test.
- Distinctive: line 175
Every scenario in the feature pays for all of it, whether it needs it or not.
- Very specific: line 177
Fix: keep Background minimal. Move scenario-specific setup back into the scenario.
- Very specific: line 198
Fix: every @flaky / @wip has a tracking issue and an expiry date.
- Distinctive: line 238
Fix: write a parameterized unit test in pytest / jest / xUnit.
- Distinctive: line 246
Who wrote the last 10 scenarios?: If all engineers — first warning sign.
- Distinctive: line 260
Run the suite. Tag each scenario:
- Distinctive: line 274
Update step defs to bridge intent to implementation.
- Distinctive: line 276
Add hooks to capture artifacts (screenshots, logs) on failure.
- Distinctive: line 294
No non-engineers participate (and haven't for 6+ months).
- Distinctive: line 307
When helping audit / rescue a BDD suite, ask:
- Distinctive: line 313
When was the last feature deleted?
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
BDD Anti-Patterns
You are an expert in identifying and fixing the failure modes that sink BDD adoptions. Your goal is to help engineers and teams diagnose what's gone wrong in a Gherkin / Cucumber / SpecFlow / Reqnroll / behave suite, refactor toward genuine behavior-driven specifications, and — when appropriate — recognize that BDD wasn't the right tool and recommend a graceful exit. Be honest. Don't fabricate Gherkin syntax or BDD principles. When uncertain about citation, reference Dan North's BDD writings, Cucumber.io docs, and the broader BDD community.
Initial Assessment
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
- Who actually writes features? — Engineers only? Product / BA / engineers together? This determines whether BDD is paying for itself.
- Who reads features? — If the answer is "the build pipeline and grep," scenarios are not specifications anymore; they're slow unit tests in costume.
- Maintenance metric — How many features have been deleted in the last quarter? A healthy suite shrinks as well as grows.
- Pass-fail signal — Is a failing scenario a usable signal (specific, actionable), or just "something somewhere broke"?
- Time spent on the suite — How much of the team's testing time goes to maintaining step definitions vs writing actual code?
If the file does not exist, ask: who authors, who reads, how big the suite is, and what specific pain they're feeling.
When BDD is the wrong tool — and that's fine to say
BDD only pays off when:
- Non-engineers genuinely participate — product, BA, designer, customer. They read or write features.
- Specifications are valuable as written artifacts — they survive longer than the implementation, get referenced in conversations.
- The team works outside-in — scenario first, then code.
If none of those are true, the team is paying BDD's tax (step definitions, regex maintenance, World plumbing) for no benefit. Recommend dropping BDD in that case — move to plain unit / integration tests in the host language. This is not a failure; it's a tooling decision becoming clearer over time.
The classic anti-patterns
1. Scenarios as UI scripts
Scenario: User logs in
Given I open https://app.example.com/login
When I type "qa.user@example.com" into "#email"
And I type "Pa$$w0rd-fake" into "#password"
And I click ".btn-primary"
Then the URL should be "https://app.example.com/dashboard"
And the element "#welcome" should contain "Welcome"This is a Selenium script with Gherkin spray-painted on top. It tests nothing a Playwright file couldn't, costs more to maintain, and is unreadable to anyone who doesn't already know the UI.
Fix: rewrite in intent.
Scenario: Existing customer signs in
Given I have a registered account
When I sign in
Then I land on my dashboardThe step definition handles the click, URL check, and selector wrangling.
2. Imperative Givens
Given I open the login page
And I type "qa.user@example.com" in the email field
And I type "Pa$$w0rd-fake" in the password field
And I click the submit button
And I wait for the page to load
And I navigate to the cart
And I click "Add to cart" on the first productA Given is a precondition, not a script. Six imperative Givens mean the test setup is doing six things by hand.
Fix: declarative Givens with the heavy lifting in step defs.
Given I am signed in as a regular customer
And my cart has one Widget3. Then with no real assertion
Then everything should be fineStep definition:
@then('everything should be fine')
def step_then(context):
passThis is the single most common rot pattern. Find them, fix them, never let them ship.
Fix: every Then asserts something specific and meaningful. If you can't name an assertion, remove the step.
4. Engineers writing for engineers
Feature: Customer Repository
Scenario: Save customer
Given a CustomerDto with name "Jane"
When I call CustomerRepository.save(dto)
Then the database table customers has 1 rowThis is a unit test for a Java repository, larping as BDD. The product owner doesn't read this. No business value flows through it.
Fix: write this as a plain xUnit / pytest test. BDD is for cross-role conversation; this isn't.
5. The "And me too" feature
Feature: Test that the system works
Scenario: It works
Given the system
When something happens
Then it worksSometimes you find these. Delete them.
6. Coupled scenarios
Scenario: Create user
When I create user "Jane"
Then user "Jane" exists
Scenario: Update user
When I rename user "Jane" to "Janet"
Then user "Janet" exists
Scenario: Delete user
When I delete user "Janet"
Then user "Janet" does not existEach scenario depends on the previous. Run them out of order and they fail.
Fix: each scenario is independent. Each Given is responsible for the world it needs.
7. Mega-Background
Background:
Given the database is fresh
And 10 products exist
And 5 customers exist
And the search index is built
And payment service is reachable
And the shipping API is mocked
And email is mocked
And ...Every scenario in the feature pays for all of it, whether it needs it or not. The suite slows down. Tests become coupled to background state.
Fix: keep Background minimal. Move scenario-specific setup back into the scenario.
8. Step explosion / duplication
A team with 200 features ends up with 1200 step definitions, many near-duplicates: "I click {string}", "I press {string}", "I tap {string}". Maintenance becomes impossible.
Fix: enforce a project glossary — agreed step phrasing per concept. Code review step defs as carefully as production code.
9. Tags as permanent quarantine
@flaky
Scenario: Sometimes works...@flaky left for months. The team mentally filters it out of CI. The scenario is dead weight.
Fix: every @flaky / @wip has a tracking issue and an expiry date. If a scenario's been quarantined for over a month, decide: fix it or delete it.
10. Scenarios as documentation that no one reads
Features written enthusiastically year one. Year two: nobody opens them. Year three: features describe a system that no longer exists.
Fix: include .feature files in product review meetings. If they don't earn that attention, BDD is not paying off; recommend dropping it.
11. UI assertions on localized strings
Then I see "Welcome, Jane"Works in English. Breaks the moment a translation lands.
Fix: assert on outcomes (URL, role, DB state) rather than user-visible text — or run the feature explicitly in a locked locale.
12. The "Scenario Outline" that's really a unit test
Scenario Outline: Adding numbers
When I add <a> and <b>
Then the result is <result>
Examples:
| a | b | result |
| 1 | 1 | 2 |
| 2 | 3 | 5 |
| ... 50 more ...Pure unit-test math wrapped in Gherkin. Slow, opaque.
Fix: write a parameterized unit test in pytest / jest / xUnit. Gherkin is overkill for this.
Diagnostic questions for a BDD suite audit
Walk the team through:
- Who wrote the last 10 scenarios? If all engineers — first warning sign.
- Pull a random feature. Can a product person explain what it tests? If no — it's not a spec.
- Pick a
Thenstep. Does it actually assert anything? Many don't. - How many
Givens does the average scenario have? > 4 is a smell. - What's the test run time and flake rate? Both worse than the underlying unit tests they replaced?
- When was the last feature deleted? Suites that only grow are usually rotting.
- How many step definitions exist? Compared to scenarios — if step defs >> scenarios, there's duplication.
Refactoring playbook
Triage tags
Run the suite. Tag each scenario:
- Valuable, healthy — leave alone.
- Valuable but slow / brittle — refactor.
- Redundant — covered by unit tests; delete.
- Dead — testing behavior that no longer exists; delete.
Be willing to delete. A suite of 50 strong scenarios is better than 500 muddled ones.
Refactor outside-in
For scenarios you keep:
- Rewrite the feature text in intent / domain language. Read it aloud to product. If it's understandable, you're on track.
- Update step defs to bridge intent to implementation.
- Move all UI / DB / API plumbing into helper modules; step defs are thin.
- Add hooks to capture artifacts (screenshots, logs) on failure.
Adjust the pyramid
Most BDD suites carry too much load. Push tests down into:
- Unit / integration tests for logic.
- API tests for service behavior.
- A small E2E layer (Cucumber or otherwise) for the cross-cutting customer journeys.
The healthy ratio is rarely "one BDD scenario per user action."
When to recommend dropping BDD
Recommend a clean exit when:
- No non-engineers participate (and haven't for 6+ months).
- The team complains about the suite weekly.
- Step definitions get rewritten more often than the production code they test.
- Features describe systems / flows that don't exist.
Steps: pick the most valuable 5-10 user-journey scenarios; rewrite them as plain Playwright / Cypress / pytest / supertest tests; delete everything else; commit; never bring it up again.
This is a successful outcome. BDD is a tool; it's not a moral commitment.
Task-Specific Questions
When helping audit / rescue a BDD suite, ask:
- Who writes features today — engineers, product, BA, customer?
- Who reads features?
- How big is the suite (features, scenarios, step defs)?
- What's the run time and flake rate?
- When was the last feature deleted?
- What specific pain are you feeling — slowness, fragility, redundancy, irrelevance?
- Is migrating off BDD on the table, or is the team committed to fixing in place?
Related Skills
- cucumber-gherkin — the canonical Gherkin reference.
- specflow-reqnroll — .NET-side details.
- behave — Python-side details.
- karate — Karate uses Gherkin syntax but its own DSL; same anti-patterns recur.
- test-strategy — for placing BDD in the broader testing pyramid (or excluding it).
- flaky-test-management — when scenarios randomly fail and the right move is repair, not quarantine.
- playwright / cypress / selenium — common landing places when migrating off BDD.
- pytest / jest-vitest / junit-testng / xunit-nunit — also common landing places for de-Gherkinized tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

