Overview
Test scenarios in the Makers BTG Tests framework are written using Gherkin syntax in Spanish. Feature files define the behavior of the application using a structured, human-readable format that serves as both documentation and executable specifications.Feature File Structure
GeneracionReporte.feature
src/test/resources/features/GeneracionReporte.feature
Gherkin Elements
Language Directive
Specifies that the feature file uses Spanish language keywords.Syntax:
#language:esThis directive must be the first line of the feature file. It tells Cucumber to interpret Gherkin keywords in Spanish (Característica, Dado, Cuando, Entonces, etc.) instead of English.Without the
#language:es directive, Cucumber would expect English keywords like Feature, Given, When, Then, causing parsing errors.Característica (Feature)
Declares the high-level feature being tested.Syntax:
Característica: <feature description>English equivalent: Feature:Característica keyword defines the business capability or feature under test. It should be followed by a concise description that explains the feature’s purpose from a business perspective.
Example
Tags
Cucumber tag used to filter and organize test scenarios.Syntax:
@tagnameTags are placed on the line immediately before a scenario or scenario outline.Purpose
Tags enable selective test execution. The CucumberRunner is configured with:@test will be executed.
Usage Examples
Common Tagging Strategies
Common Tagging Strategies
- @test - Standard test execution
- @smoke - Critical path tests for quick validation
- @regression - Full regression test suite
- @integration - Tests that require external systems
- @wip - Work in progress, excluded from regular runs
- @ignore - Temporarily disabled tests
Esquema del escenario (Scenario Outline)
Defines a parameterized test scenario that runs multiple times with different data.Syntax:
Esquema del escenario: <scenario description>English equivalent: Scenario Outline:<variable_name> and values are provided in the Ejemplos (Examples) table.
Example
The
[Happy Path] prefix in the scenario name is a naming convention to indicate this tests the main success flow. You can use [Unhappy Path] for error scenarios or [Edge Case] for boundary conditions.Gherkin Step Keywords
Scenarios are composed of steps using Given-When-Then syntax:Dado (Given)
Defines the initial context or preconditions for the scenario.Syntax:
Dado <precondition statement>English equivalent: GivenPurpose
Given steps set up the test environment and establish the initial state before any actions are performed.Example
Cuando (When)
Defines the action or event that triggers the behavior being tested.Syntax:
Cuando <action statement>English equivalent: WhenPurpose
When steps represent the user’s actions or system events that cause a change in the application state.Example with Parameters
Entonces (Then)
Defines the expected outcome or assertion that verifies the behavior.Syntax:
Entonces <expected outcome>English equivalent: ThenPurpose
Then steps verify that the system behaves as expected after the When action is performed.Example
Parameters and Data Tables
String Parameters
String parameters are enclosed in double quotes in the feature file.In scenario outlines, use angle brackets for variables:
"<variable_name>"Example
Ejemplos (Examples) Table
Provides test data for scenario outlines in a table format.Syntax:English equivalent:
Examples:Structure
The Examples table consists of:- Header row - Column names that match variable names in the scenario outline
- Data rows - Each row represents one test execution with specific values
Example
The report ID to be generated. Replaces
<report> placeholders in the scenario.The company name for the report. Replaces
<company> placeholders in the scenario.The date for the report in YYYY-MM-DD format. Replaces
<report_date> placeholders in the scenario.Multiple Data Rows
You can add multiple rows to run the same scenario with different data:Complete Scenario Execution
How Cucumber Processes This Feature File
How Cucumber Processes This Feature File
When the CucumberRunner executes the feature file:
- Parse language directive - Cucumber switches to Spanish keyword interpretation
- Read feature description - “Generación de reportes desde la web de Chronos”
- Check tags - Only scenarios with
@testtag are selected (configured in runner) - Load scenario outline - Read the scenario template with
<variable>placeholders - Process Examples table - For each data row:
- Replace
<report>with417 - Replace
<company>withcompañia 1 - Replace
<report_date>with2026-02-01
- Replace
- Execute steps - Call corresponding step definition methods:
el_usuario_ingresa_a_la_web_de_chronos()ingrese_los_datos_del_reporte_para_la_compañia_segun_la_fecha("417", "compañia 1", "2026-02-01")se_genera_el_reporte_de_manera_exitosa("417")
- Report results - Generate test reports showing pass/fail status
Writing New Scenarios
Creating a New Feature File
- Create a new
.featurefile insrc/test/resources/features/ - Start with the language directive:
#language:es - Add a
Característica:description - Write scenarios using
Dado,Cuando,Entonceskeywords - Add appropriate tags (e.g.,
@test)
Example: New Feature File
Additional Spanish Keywords
Equivalent to
And in English. Used to add additional steps of the same type.Equivalent to
But in English. Used for negative assertions or contrasting conditions.Equivalent to
Scenario in English. Used for single-execution scenarios without examples.Best Practices
Feature File Writing Guidelines
Feature File Writing Guidelines
- Use descriptive names - Scenario names should clearly indicate what is being tested
- One feature per file - Keep feature files focused on a single business capability
- Keep scenarios independent - Each scenario should be executable in isolation
- Use meaningful tags - Organize scenarios with tags for easy filtering
- Write declaratively - Focus on what, not how (“the user logs in” vs. “the user clicks the login button”)
- Limit step count - Keep scenarios between 3-7 steps for readability
- Use examples judiciously - Include boundary values and representative samples
- Maintain consistency - Follow the same phrasing patterns across scenarios
Common Anti-Patterns to Avoid
Common Anti-Patterns to Avoid
❌ Overly technical steps - Avoid UI implementation details in feature files❌ Too many examples - Don’t use scenario outlines as data-driven tests with hundreds of rows❌ Missing tags - Always tag scenarios appropriately for filtering❌ Duplicate scenarios - Use scenario outlines instead of copying similar scenarios❌ Hard-coded values - Use examples tables for data that might change
Related Documentation
- CucumberRunner - Configures which feature files to execute
- Step Definitions - Implements the Java code for each Gherkin step
Feature File Location
features directory to be discovered by the CucumberRunner via the @SelectClasspathResource("features") annotation.