← Back to libraryQuestion 250 of 468
🥒Cucumber / BDDBeginner

Feature Files

📌 Definition:

A feature file (.feature) is a plain-text file containing one Feature and its scenarios written in Gherkin. It is the executable specification and the entry point Cucumber reads.

📖 Detailed Explanation:

Feature files live in a resources/features folder (by convention) and describe one capability per file (Login.feature, Checkout.feature). A file begins with an optional narrative (As a... I want... So that...) under Feature:, followed by scenarios. Keeping features focused and named by capability aids organization and discoverability. Feature files are version-controlled alongside code so the specification evolves with the product. The narrative and scenario titles serve as documentation; well-organized feature files let stakeholders find and read behavior without touching code.

🔑 Key Points:
  • One Feature (capability) per .feature file
  • Optional narrative: As a... I want... So that...
  • Stored under a features folder; version-controlled
  • Named by capability (Login.feature) for discoverability
🌍 Real-World Example:

Checkout.feature groups all checkout scenarios (empty cart, discount applied, payment failure) under one Feature with a narrative, so anyone can read the checkout behavior in one place.

🎯 Scenario-Based Interview Question:

How should you organize scenarios across feature files, and why not put everything in one big file?