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

@Before hook is only executing once per feature file and not per scenario #2966

Open
zainafzal-tek opened this issue Jan 29, 2025 · 1 comment

Comments

@zainafzal-tek
Copy link

👓 What did you see?

The @before hook is only executing once per feature file not per scenario when running scenarios in parallel, When I have the cucumber.execution.parallel.config.fixed.parallelism and cucumber.execution.parallel.config.fixed.max-pool-size set to less than the scenarios in a feature file.

✅ What did you expect to see?

Before hook executing before every scenario

📦 Which tool/library version are you using?

Junit BOM 5.11.3
Serenity Core 4.2.14
Cucumber-junit-platform-engine 7.20.1

🔬 How could we reproduce it?

  1. Have a feature file with 10+ scenarios
  2. Have a threadlocal<Collection> with lazy loading and a static getter with the values set in the before hook method to grab sourcetagnames or have a stringbuffer that is getting the sourcetagnames. print values out before exiting method.
  3. Set the cucumber.execution.parallel.config.fixed.parallelism and cucumber.execution.parallel.config.fixed.max-pool-size to less than the scenarios in feature file while making sure all scenarios run (common tag at top of feature file, separate tags on scenarios)
  4. Run it via maven

📚 Any additional context?

I have tried to use a stringbuffer and get the tags in the case my thread syncing method was the issue, same thing happens.

@mpkorstanje
Copy link
Contributor

Your reproducer sounds quite complicated. And that makes it likely that the problem sits in the code you have written. Additionally you're using Serenity which is a different project.

Please clone the https://github.com/cucumber/cucumber-java-skeleton and try to reproduce your problem with it.

To verify that the hook is executed for each scenario a print statement should suffice.

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

No branches or pull requests

2 participants