Open
Description
π What did you see?
@Singleton
instances do not work in parallel execution, instead one instance per thread is created.
β What did you expect to see?
I expected only one instance of @Singleton
bound classes to be created:
cucumber-jvm/cucumber-guice/README.md
Lines 72 to 81 in 6ec14f7
π¦ Which tool/library version are you using?
cucumber-jvm (core+guice) 7.20.1
π¬ How could we reproduce it?
Test case that reproduce the bug: loveleif@1a52642.
- Bind a class in
Singleton
scope. - Inject the singleton class in a scenario.
- Start a test suite with parallel execution.
- There will be multiple instances created, depending on how many threads are used.
π Any additional context?
My use case is query language testing for a database. Starting and stopping the database is time consuming, so we re-use the dbms between scenarios to drastically reduce execution time. A custom backend registers before/after all hooks to the glue that starts/stops the database (since regular before/after all hooks can't use dependency injection, but backends have access to Lookup
).