Skip to content

Feature Files

Organizing your feature files well makes tests easier to find, maintain, and understand.

Directory Structure

One Feature Per File

Each feature file should focus on a single feature:

tests/Behaviors/
├── authentication/
│   ├── login.feature
│   ├── logout.feature
│   └── password-reset.feature
├── cart/
│   ├── add-items.feature
│   ├── remove-items.feature
│   └── checkout.feature
└── admin/
    ├── user-management.feature
    └── reports.feature

Group by Domain

Organize by business domain, not technical concerns:

# Good: Domain-based
tests/Behaviors/
├── orders/
├── payments/
├── shipping/
└── customers/

# Avoid: Technical grouping
tests/Behaviors/
├── api/
├── database/
├── ui/
└── services/

Naming Conventions

File Names

Use lowercase with hyphens, describing the behavior:

# Good
user-registration.feature
shopping-cart-checkout.feature
password-reset-flow.feature

# Avoid
test1.feature
users.feature
misc.feature
UserRegistration.feature

Feature Names

Be specific about what the feature does:

gherkin
# Good
Feature: Shopping Cart Checkout
Feature: Password Reset via Email
Feature: Admin User Management

# Avoid
Feature: Cart
Feature: Password
Feature: Admin Stuff

Feature Descriptions

User Story Format

Include who, what, and why:

gherkin
Feature: Shopping Cart Checkout
  As a customer
  I want to complete my purchase
  So that I can receive my ordered products

Free-Form Description

Or use prose for complex features:

gherkin
Feature: Credit Application Processing
  Agricultural credit applications are evaluated based on
  the farmer's land holdings. The minimum land requirement
  is 5 hectares per 10,000 TL of requested credit.

  Applications exceeding the land-to-credit ratio are
  automatically rejected. Approved applications proceed
  to the verification stage.

Combined Approach

gherkin
Feature: Order Fulfillment
  As a warehouse manager
  I want orders to be automatically assigned to pickers
  So that fulfillment is efficient and trackable

  Orders are assigned based on picker availability and
  proximity to the items. Priority orders (next-day delivery)
  are assigned first, followed by standard orders.

Tag Organization

Feature-Level Tags

Apply to all scenarios in the file:

gherkin
@api @orders @critical
Feature: Order Processing
  ...

Scenario-Level Tags

For specific scenarios:

gherkin
Feature: User Authentication

  @smoke @fast
  Scenario: Successful login
    ...

  @edge-case @slow
  Scenario: Login with expired session
    ...

Standard Tag Conventions

TagPurpose
@smokeCritical path tests
@slowTests taking > 5 seconds
@wipWork in progress
@skipTemporarily disabled
@P1, @P2, @P3Priority levels
@regressionRegression suite
@api, @ui, @integrationTest type

Released under the MIT License.