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

[Spring] Support @CucumberContextConfiguration as a meta-annotation #2630

Merged

Conversation

m-schlatt
Copy link
Contributor

@m-schlatt m-schlatt commented Oct 24, 2022

Using @CucumberContextConfiguration as a meta-annotation caused a CucumberBackendException because SpringFactory only realized raw use of the class. Method hasCucumberContextConfiguration does now recognize the use of @CucumberContextConfiguration as meta-annotation or with inheritance.

Also SpringBackend#loadGlue filters out abstract classes and interfaces to not try to instantiate what cannot be instantiated.

🤔 What's changed?

Using @CucumberContextConfiguration as a meta-annotation caused a CucumberBackendException because SpringFactory only realized raw use of the class. the method SpringFactory#hasCucumberContextConfiguration does now recognize the use of @CucumberContextConfiguration as meta-annotation or frominheritance.

Also SpringBackend#loadGlue filters out abstract classes and interfaces to not try to instantiate what cannot be instantiated.

⚡️ What's your motivation?

Fixes: #2491

🏷️ What kind of change is this?

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

♻️ Anything particular you want feedback on?

Did I get the suggested changes right? Also code fit and quality

📋 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. - don't think so, but please let me know if otherwise!
    • I have updated the documentation accordingly.

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

…tion

 Using @CucumberContextConfiguration as a meta-annotation caused a CucumberBackendException because SpringFactory only realized raw use of the class. Method hasCucumberContextConfiguration does now recognize the use of @CucumberContextConfiguration as meta-annotation or with inheritance.

 Also SpringBackend#loadGlue filters out abstract classes and interfaces to not try to instantiate what cannot be instantiated.
@codecov
Copy link

codecov bot commented Oct 24, 2022

Codecov Report

Merging #2630 (bfb1e2b) into main (aa05551) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #2630      +/-   ##
============================================
- Coverage     84.79%   84.77%   -0.03%     
+ Complexity     2693     2686       -7     
============================================
  Files           322      322              
  Lines          9544     9530      -14     
  Branches        908      903       -5     
============================================
- Hits           8093     8079      -14     
  Misses         1120     1120              
  Partials        331      331              
Impacted Files Coverage Δ
...rc/main/java/io/cucumber/spring/SpringBackend.java 100.00% <100.00%> (ø)
...rc/main/java/io/cucumber/spring/SpringFactory.java 87.50% <100.00%> (-4.17%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mpkorstanje mpkorstanje changed the title #2491 Support @CucumberContextConfiguration as a meta-annotation [Spring] Support @CucumberContextConfiguration as a meta-annotation Oct 25, 2022
Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

Cheers! Looks good in principle, but I've got some style remarks and questions.

Also don't forget to update the CHANGELOG.md.

@m-schlatt
Copy link
Contributor Author

Wow, thanks for your prompt reply and all your remarks and suggestions! I wasn't able to fix all points today, but I will see that I can do another commit tomorrow. I will also look into the AnnotatedElementUtils' docs again and add some more tests to clarify.

…tion

Adds suggestions from review: renames test package, more focused testing and updates the changelog.

Method hasCucumberContextConfiguration now uses AnnotatedElementUtils isAnnotated with considers all merged annotations (including inherited and meta-annotation).
Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

Looks good. Do consider adding a note to the javadoc of CucumberContextConfiguration to note that the annotation can be used as a meta annotation. Please also check the surrounding code for error messages (e.g. checkOnlyOneClassHasCucumberContextConfiguration) to see if it need to mention (meta-)annotation.

CHANGELOG.md Show resolved Hide resolved
@mpkorstanje mpkorstanje merged commit 3615fc7 into cucumber:main Nov 1, 2022
@aslakhellesoy
Copy link
Contributor

Hi @m-schlatt,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

@mpkorstanje
Copy link
Contributor

@m-schlatt cheers, I've got ahead and merged and released the change.

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.

Support @CucumberContextConfiguration as a meta-annotation
3 participants