File name not displayed when error caught in step file
How to reproduce
In a 'steps' file(s), for a step used in an existing scenario, introduce an intentional error:
# features/steps/ExperimentSteps.jl
@given("a machine filled with coffee beans") do context
# Should be 'Machine(coffee=5.0)' not 'machine(coffee=5.0)'
context[:machine] = machine(coffee=5.0)
end
Run the tests
(MPackage) pkg> test
Testing MPackage
...
Testing Running tests...
Feature: Making Coffee
Scenario: Making a regular coffee
Given a machine filled with coffee beans
Exception: UndefVarError(:machine)
(::var"#3#6")(context::Behavior.StepDefinitionContext) at string:18
Instead of the name of the file, we get 'string:18'
Solution
The built-in include_string (base/loading.jl) can take an optional filename argument, the default value being 'string'.
With the file name being passed:
Exception: UndefVarError(:machine)
(::var"#3#6")(context::Behavior.StepDefinitionContext) at ExperimentSteps.jl:18
#2 at stepdefinitions.jl:140 [inlined]
Hi! Sorry, I've been focused on other things recently, and completely missed that I had this PR waiting. Thanks for the improvement! I'll make a patch release that includes this.
Enhancement
File name not displayed when error caught in step file
How to reproduce
In a 'steps' file(s), for a step used in an existing scenario, introduce an intentional error:
Run the tests
Instead of the name of the file, we get 'string:18'
Solution
The built-in
include_string
(base/loading.jl
) can take an optionalfilename
argument, the default value being 'string'.With the file name being passed: