-
Notifications
You must be signed in to change notification settings - Fork 9
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
Cached injector for common modules #3
Conversation
What's your use case? Why would you want to share singleton instances across tests? |
At least connection pools to DB or some shared state (I know that shared states is bad idea, but sometimes it very helpful) |
Ideally you would fake out the DB connection so it isn't terribly expensive, but I can see some value in a feature like this. I don't think it should be enabled by default, but adding some annotation that lets users opt into shared injectors would be reasonable |
I add @SharedInjectors annotation for cached inhectors enabled |
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/main/java/name/falgout/jeffrey/testing/junit/guice/GuiceExtension.java
Outdated
Show resolved
Hide resolved
guice-extension/src/test/java/name/falgout/jeffrey/testing/junit/guice/SharedInjectorsTest.java
Outdated
Show resolved
Hide resolved
Looks good, thanks for bearing with me! |
This will be available as part of 1.1.0 |
In original implementantion for each test guice create new injector and if we bind somting in scope SINGLETON - that not work as expected.
In this pr I provide basic implementation of cache for injectors with same modules - can you provide some feedback? @JeffreyFalgout