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] Instantiate TestContextManager synchronously #2687

Merged
merged 6 commits into from
Jan 27, 2023

Conversation

ntthaibk
Copy link
Contributor

@ntthaibk ntthaibk commented Jan 26, 2023

🤔 What's changed?

As suggestion from #help channel, I'm trying to put TestContextManager initiation to the synchronized block inside start method of TestContextAdaptor to resolve the racing problem of spring boot 3 cucumber test.

⚡️ What's your motivation?

Fixes #2686

🏷️ 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.

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 pretty decent. If you build a SNAPSHOT (mvn clean install -DskipTests) and use that in your reproducer, does the problem go away?

@ntthaibk
Copy link
Contributor Author

@mpkorstanje hi, just want to inform that I’ve tried the SNAPSHOT version and it work!!!! Thanks a lot for your help ❤️

@ntthaibk
Copy link
Contributor Author

ntthaibk commented Jan 27, 2023

Just updated the constructor of TestContextAdaptor to receive the Supplier of TestContextManager instead, so that the unit test for cucumber-spring has passed

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #2687 (63ac82d) into main (e5ff5f6) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #2687      +/-   ##
============================================
- Coverage     84.68%   84.68%   -0.01%     
- Complexity     2680     2682       +2     
============================================
  Files           322      322              
  Lines          9450     9449       -1     
  Branches        899      899              
============================================
- Hits           8003     8002       -1     
  Misses         1120     1120              
  Partials        327      327              
Impacted Files Coverage Δ
...rc/main/java/io/cucumber/spring/SpringFactory.java 87.09% <100.00%> (-0.41%) ⬇️
...in/java/io/cucumber/spring/TestContextAdaptor.java 93.80% <100.00%> (ø)

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 Move TestContextManager init to start() block of TestContextAdaptor [Spring] Instantiate TestContextManager synchronously Jan 27, 2023
@mpkorstanje mpkorstanje merged commit 287f718 into cucumber:main Jan 27, 2023
@aslakhellesoy
Copy link
Contributor

Hi @ntthaibk,

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

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.

Can not run parallel test with Spring boot 3 and AOT
3 participants