-
Notifications
You must be signed in to change notification settings - Fork 38.4k
TestContext to become subclassable [SPR-5428] #10102
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
Comments
Sam Brannen commented Hi Grzegorz, The visibility of TestContext's constructor and methods is intentionally limited in order to hide the implementation details of the context cache, etc. Developers typically should have no need to instantiate or subclass TestContext. Rather, developers will typically use a TestContextManager directly, which in turns instantiates and configures the TestContext that it manages. What concrete use case do you have which prompted you to raise this JIRA issue? Moreover, why would you want protected access to loadApplicationContext() and contextKeyString()? Regards, Sam |
Grzegorz Olędzki commented Hi Sam, The use case is to have a different way of application contexts being constructed for tests. In our setup there was a need for using parent link between containers instead of setting up a different container based on the sum of file locations. To be more precise, follow the example:
Using standard
The approach we prefer is to have:
It seems to me that it's easier doable being able to subclass Regards, |
Piotr Findeisen commented Hi, I've just stumbled upon that. I wanted to mock (Mockito) I've ended up with not-so readable reflection-based workaround (fest-reflect saved my life), instead of straight-forward mock
All this hackish code should not be necessary. |
Piotr Findeisen commented For me, inability (since I would not call my workaround "an ability") to test listeners is a Bug, and not with a minor priority. Could you please therefore raise the priority a bit? Or perhaps I should report a separate issue for that (since my problem is not 100% equal to the original one)? |
Sam Brannen commented Piotr Findeisen, there's no need to create a new issue since your wish is already addressed in #12348. So feel free to watch that issue instead of this one for testability of listeners. Regards, Sam |
Sam Brannen commented In light of the fact that both #10284 and #12348 have been resolved since this issue was raised, I am resolving this issue as Won't Fix. However, if you feel that there is still a need for elements of this issue in spite of recent changes in the TestContext framework, please provide feedback here. Thanks! Sam |
Grzegorz Olędzki opened SPR-5428 and commented
org.springframework.test.context.TestContext declares a package-protected constructor (the only constructor there).
It would be better to make it protected instead - so that one can subclass it in his/her own package.
The same would apply to methods there - why not make them protected instead of private:
loadApplicationContext()
contextKeyString()
Affects: 2.5.6
Issue Links:
The text was updated successfully, but these errors were encountered: