Skip to content

fix(errors): Fix expected Step argument count for steps with context.Context#679

Merged
tigh-latte merged 4 commits intocucumber:mainfrom
tigh-latte:fix/stepdef-error
Mar 19, 2025
Merged

fix(errors): Fix expected Step argument count for steps with context.Context#679
tigh-latte merged 4 commits intocucumber:mainfrom
tigh-latte:fix/stepdef-error

Conversation

@tigh-latte
Copy link
Copy Markdown
Member

🤔 What's changed?

Currently, if a step function is defined as:

ctx.Step(`^the input is "([^"]*)"$`, func(ctx context.Context, a, b string) error {
    return nil
}

Then when executing, we get the following error because it counts context.Context as an expected error:

func expected more arguments than given: expected 3 arguments, matched 1 from step

This fixes the error to say

func expected more arguments than given: expected 2 arguments, matched 1 from step

⚡️ What's your motivation?

Just noticed this today and thought I'd fix it.

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

♻️ Anything particular you want feedback on?

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.87%. Comparing base (153db4e) to head (e9a3f72).
Report is 28 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #679      +/-   ##
==========================================
- Coverage   83.21%   77.87%   -5.34%     
==========================================
  Files          28       41      +13     
  Lines        3413     4050     +637     
==========================================
+ Hits         2840     3154     +314     
- Misses        458      778     +320     
- Partials      115      118       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tigh-latte tigh-latte merged commit 4a4fd8a into cucumber:main Mar 19, 2025
6 of 7 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.

2 participants