Cucumber.StepError exception (Cucumber v0.4.0)
View SourceException raised when a step in a Cucumber scenario fails.
This module provides detailed error reporting for two main failure cases:
- A step has no matching step definition
- A step's implementation raises an error or returns
{:error, reason}
The error messages include helpful context like:
- The failing step text and location
- The scenario name and feature file
- A history of previously executed steps
- Suggestions for implementing missing steps
Summary
Functions
Creates a new step error for a step execution failure.
Creates a new step error for a missing step definition.
Types
Functions
Creates a new step error for a step execution failure.
When a step implementation raises an exception or returns {:error, reason}
,
this function creates a detailed error message with context about the failure.
Parameters
step
- TheGherkin.Step
struct that failed during executionpattern
- The step pattern that matched the stepfailure_reason
- The exception or error reasonfeature_file
- The path to the feature file containing the stepscenario_name
- The name of the scenario containing the stepstep_history
- A list of previously executed steps with their status
Returns
Returns a Cucumber.StepError
struct with a formatted error message and context.
Examples
The error message will include details like:
Step failed:
Then the result should be 10
in scenario "Basic math" (test/features/calculator.feature:12)
matching pattern: "the result should be {int}"
Expected 10 but got 9
Step execution history:
[passed] Given I have entered 5 into the calculator
[passed] And I have entered 4 into the calculator
[passed] When I press add
[failed] Then the result should be 10
Creates a new step error for a missing step definition.
When a step in a feature file doesn't match any step definition, this function creates a helpful error message that includes a suggestion for implementing the missing step.
Parameters
step
- TheGherkin.Step
struct that has no matching definitionfeature_file
- The path to the feature file containing the stepscenario_name
- The name of the scenario containing the stepstep_history
- A list of previously executed steps with their status
Returns
Returns a Cucumber.StepError
struct with a formatted error message and context.
Examples
The error message will include a suggested implementation like:
step "I click the submit button", context do
# Your step implementation here
context
end