$npx -y skills add PramodDutta/qaskills --skill bdd-cucumberBehavior-Driven Development skill using Cucumber, covering feature files, step definitions, Gherkin best practices, data tables, scenario outlines, and hooks.
| 1 | # BDD/Cucumber Patterns Skill |
| 2 | |
| 3 | You are an expert QA engineer specializing in Behavior-Driven Development (BDD) with Cucumber. When the user asks you to write, review, or improve Cucumber feature files and step definitions, follow these detailed instructions. |
| 4 | |
| 5 | ## Core Principles |
| 6 | |
| 7 | 1. **Business language** -- Feature files must use domain language that non-technical stakeholders understand. |
| 8 | 2. **Declarative over imperative** -- Describe what the user does, not how the UI works. |
| 9 | 3. **Single scenario, single behavior** -- Each scenario tests exactly one business rule. |
| 10 | 4. **Reusable step definitions** -- Steps should be generic enough to reuse across features. |
| 11 | 5. **Living documentation** -- Feature files are the single source of truth for behavior. |
| 12 | |
| 13 | ## Project Structure (TypeScript) |
| 14 | |
| 15 | ``` |
| 16 | features/ |
| 17 | auth/ |
| 18 | login.feature |
| 19 | registration.feature |
| 20 | password-reset.feature |
| 21 | products/ |
| 22 | product-listing.feature |
| 23 | product-search.feature |
| 24 | checkout/ |
| 25 | cart.feature |
| 26 | payment.feature |
| 27 | step-definitions/ |
| 28 | auth.steps.ts |
| 29 | products.steps.ts |
| 30 | checkout.steps.ts |
| 31 | common.steps.ts |
| 32 | support/ |
| 33 | world.ts |
| 34 | hooks.ts |
| 35 | custom-parameter-types.ts |
| 36 | pages/ |
| 37 | login.page.ts |
| 38 | products.page.ts |
| 39 | cucumber.js |
| 40 | tsconfig.json |
| 41 | ``` |
| 42 | |
| 43 | ## Project Structure (Java) |
| 44 | |
| 45 | ``` |
| 46 | src/ |
| 47 | test/ |
| 48 | java/com/example/ |
| 49 | steps/ |
| 50 | AuthSteps.java |
| 51 | ProductSteps.java |
| 52 | CommonSteps.java |
| 53 | pages/ |
| 54 | LoginPage.java |
| 55 | ProductsPage.java |
| 56 | hooks/ |
| 57 | Hooks.java |
| 58 | runners/ |
| 59 | TestRunner.java |
| 60 | resources/ |
| 61 | features/ |
| 62 | auth/ |
| 63 | login.feature |
| 64 | registration.feature |
| 65 | products/ |
| 66 | product-listing.feature |
| 67 | ``` |
| 68 | |
| 69 | ## Writing Feature Files |
| 70 | |
| 71 | ### Good Feature File |
| 72 | |
| 73 | ```gherkin |
| 74 | Feature: User Login |
| 75 | As a registered user |
| 76 | I want to log into the application |
| 77 | So that I can access my personalized dashboard |
| 78 | |
| 79 | Background: |
| 80 | Given the login page is displayed |
| 81 | |
| 82 | @smoke @auth |
| 83 | Scenario: Successful login with valid credentials |
| 84 | When I log in with valid credentials |
| 85 | Then I should see the dashboard |
| 86 | And I should see a welcome message |
| 87 | |
| 88 | @auth @negative |
| 89 | Scenario: Login fails with incorrect password |
| 90 | When I log in with an incorrect password |
| 91 | Then I should see an error message "Invalid email or password" |
| 92 | And I should remain on the login page |
| 93 | |
| 94 | @auth @negative |
| 95 | Scenario: Login fails with non-existent email |
| 96 | When I log in with a non-registered email |
| 97 | Then I should see an error message "Invalid email or password" |
| 98 | |
| 99 | @auth @security |
| 100 | Scenario: Account locks after multiple failed attempts |
| 101 | When I attempt to log in 5 times with incorrect passwords |
| 102 | Then my account should be temporarily locked |
| 103 | And I should see a message about account lockout |
| 104 | ``` |
| 105 | |
| 106 | ### Scenario Outline (Data-Driven) |
| 107 | |
| 108 | ```gherkin |
| 109 | Feature: Form Validation |
| 110 | As a user |
| 111 | I want to see clear validation messages |
| 112 | So that I can correct my input |
| 113 | |
| 114 | @validation |
| 115 | Scenario Outline: Email validation |
| 116 | Given I am on the registration page |
| 117 | When I enter "<email>" in the email field |
| 118 | And I submit the form |
| 119 | Then I should see the validation message "<message>" |
| 120 | |
| 121 | Examples: |
| 122 | | email | message | |
| 123 | | | Email is required | |
| 124 | | not-an-email | Please enter a valid email | |
| 125 | | @missing.com | Please enter a valid email | |
| 126 | | valid@example.com | | |
| 127 | |
| 128 | @validation |
| 129 | Scenario Outline: Password strength validation |
| 130 | Given I am on the registration page |
| 131 | When I enter "<password>" in the password field |
| 132 | And I move to the next field |
| 133 | Then the password strength indicator should show "<strength>" |
| 134 | |
| 135 | Examples: |
| 136 | | password | strength | |
| 137 | | abc | weak | |
| 138 | | abcdef12 | medium | |
| 139 | | SecurePass123! | strong | |
| 140 | ``` |
| 141 | |
| 142 | ### Data Tables |
| 143 | |
| 144 | ```gherkin |
| 145 | Scenario: Create multiple users |
| 146 | Given the following users exist: |
| 147 | | email | name | role | |
| 148 | | admin@example.com | Admin User | admin | |
| 149 | | user1@example.com | User One | user | |
| 150 | | user2@example.com | User Two | viewer | |
| 151 | When I navigate to the user management page |
| 152 | Then I should see 3 users in the list |
| 153 | |
| 154 | Scenario: Verify user profile details |
| 155 | Given I am logged in as "admin@example.com" |
| 156 | When I view my profile |
| 157 | Then my profile should contain: |
| 158 | | Field | Value | |
| 159 | | Name | |