Context & Scope Control (Background & Tagging Strategy)
Every feature file eventually grows past a handful of scenarios. When it does, two problems creep in quietly: the same setup line gets copy-pasted into every scenario, and the file becomes a wall of text with no way to tell which scenarios matter most. This module fixes both.
Why This Module Matters
Open any real-world feature file with a dozen scenarios and you'll usually find the same Given line repeated at the top of each one — "Given an admin user is logged in," "Given the product catalog contains 50 items." Copy-paste setup isn't just tedious to write; it's expensive to maintain. Change the precondition once and you now have a dozen places to update, and it's easy to miss one.
The second problem is invisible until a release is on fire: someone needs to run "just the important stuff" in five minutes, not the full 200-scenario suite. Without a tagging convention, there's no way to answer "which of these scenarios absolutely cannot break?" except by reading every line.
What You'll Learn
- The problem of a precondition duplicated across every scenario in a feature file, and why it's a maintenance liability, not just visual noise
Background:— the keyword that runs its steps before every scenario in the feature, written exactly once- How to decide what truly belongs in
Backgroundversus what should stay local to one scenario (the DRY-vs-hidden-context trade-off) - Tag syntax (
@tagname) and the standard priority conventions:@smoke,@critical,@regression, and the meaning of leaving a scenario untagged - How tags let both a test runner and a human reader filter and prioritize a suite at a glance
Your Practice Challenge
After the lessons, you'll take on Background & Tags — an interactive challenge with an admin-panel feature file containing four scenarios that all currently repeat the same precondition. You decide whether that precondition should move into a Background: block, and pick the correct priority tag (@critical, @smoke, @regression, or none) for each of the four scenarios based on their business importance. Get every choice right to unlock "Perfectly Organized Feature File" — miss the Background extraction, mistag a single scenario, or get both wrong at once (the worst case, "Scope Chaos") to discover the other outcomes. Seven outcomes total to find.