Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement quick fix for generating step definitions #45

Merged
merged 3 commits into from
May 24, 2022

Conversation

aslakhellesoy
Copy link
Contributor

@aslakhellesoy aslakhellesoy commented May 23, 2022

🤔 What's changed?

Add quick fix to generate snippets for undefined step definitions.

TODO:

  • Detect what language to use for snippets
    • If the settings specify a preferred language, use that
    • Otherwise, scan the glue path and detect the most used language
    • Otherwise, try to determine the language from the presence of other files (pom.xml, package.json, Gemfile etc)
  • Determine what file to add the snippet into
    • Find existing glue files, split camel/underscore into words, choose the file with most words present in "snippet words"
    • Otherwise, most recently edited glue file
    • Otherwise, create a new file directly under the glue glob called step_definitions.${ext} - the template context will have one extra property:
      • moduleWords - e.g. ['foo', 'bar'], which the template can use to add e.g. package foo.bar; at the top
        • In order to compute moduleWords we need to strip away any path prefixes (such as src/test/java before making moduleWords)

⚡️ What's your motivation?

Write step definitions quicker, without having to run Cucumber to see snippets. Also to have snippets added to code automatically.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

See related PR: cucumber/language-service#46

📋 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.

@aslakhellesoy aslakhellesoy marked this pull request as draft May 23, 2022 08:17
@aslakhellesoy aslakhellesoy marked this pull request as ready for review May 24, 2022 13:56
@aslakhellesoy aslakhellesoy merged commit 5559c26 into main May 24, 2022
@aslakhellesoy aslakhellesoy deleted the generate-step-definitions branch May 24, 2022 14:01
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.

1 participant