Skip to content

Conversation

@acoulton
Copy link
Contributor

@acoulton acoulton commented Oct 2, 2025

Because of the stage where it is thrown, the exception is treated as an overall fatal error. This meant that Behat does not output any detail on the feature file / step it was parsing when it encountered the unexpected argument. As a result, users had no information on the cause of the error and would have to check their features / steps manually.

Instead, include the name of the function and (where possible) the feature and step within the exception message. This will still mean that users have to fix these one at a time (Behat will exit on the first such exception) but they should at least now be able to locate the issue.

As reported by @AlexSkrypnyk in #1614 (comment)

@acoulton acoulton force-pushed the bug-step-argument-exception-context branch from 936afc9 to af309a6 Compare October 2, 2025 14:07
r
<word2>
d
""" No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding the fine LF in all those feature files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks - I'd just captured them from the previous inline strings and hadn't noticed they were missing.

So that it's easier to run individual examples and see the actual
output, and to have completion etc for them.
Because of the stage where it is thrown, the exception is treated as
an overall fatal error. This meant that Behat does not output any detail
on the feature file / step it was parsing when it encountered the
unexpected argument. As a result, users had no information on the cause
of the error and would have to check their features / steps manually.

Instead, include the name of the function and (where possible) the
feature and step within the exception message. This will still mean that
users have to fix these one at a time (Behat will exit on the first such
exception) but they should at least now be able to locate the issue.
@acoulton acoulton force-pushed the bug-step-argument-exception-context branch from 8bdd342 to add8457 Compare October 2, 2025 14:18
Copy link
Contributor

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acoulton great stuff, thanks for fixing this (and converting the tests at the same time 😄 )

@jdeniau
Copy link
Contributor

jdeniau commented Oct 2, 2025

Thanks @acoulton for this fix!

@acoulton acoulton merged commit eb1bcc6 into Behat:master Oct 2, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants