-
Notifications
You must be signed in to change notification settings - Fork 369
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
Support SingleQueryCountHolder
in SQLStatementCountValidator
#565
Comments
The Bootstrapping an entire Spring Boot context just to test a single business method is not very efficient. It's worth testing the service method and its associated Repository calls. Therefore, I don't see any reason why this utility should use However, it can surely be done via a configuration property that you can set via:
The However, the But, to make it backward compatible, the old If you want to provide a Pull Request with these changes, then I could integrate this sooner rather than later. |
If the application is thin enough (e.g. CRUD), having separate data integration tests are not always worth the effort in my opinion. It's easier to test the app as a whole. Regarding the implementation of this feature, the tricky part is that the query count strategy also has to be set on the proxy datasource level, so changing Anyway, as this util lib only provides an assertion layer on top of the proxy, it can be worked around rather easily. I just wondered if it's something tha could fit into this library. |
Unless Spring Boot can start in 50 ms, then it will always be worth it. I have a very small Spring Boot app that uses this strategy. My integration tests run in 50-500 ms while bootstrapping Spring Boot would take 5-10 seconds. And this is a small Spring Boot app. So, until Spring native becomes mainstream, I don't see why anyone would want to bootstrap a Spring Boot app to test a single business use case.
The solution will use the
It doesn't need to be a workaround. It can use the right strategy since
The real test is whether someone will want to spend the time to implement it. If it's worth implementing it, then it's useful. If no one took the time to implement it, then it's not worth it. |
By workaround I meant that one can create |
Currently,
SQLStatementCountValidator
relies on thenet.ttddyy.dsproxy.QueryCountHolder
class which holds the query counts in aThreadLocal
field. However,datasource-proxy
library also supports a differentQueryCountStrategy
calledSingleQueryCountHolder
which can count queries across multiple threads.This strategy can be useful for example when testing against a web API where each request has its dedicated thread. In this case the default
ThreadQueryCountHolder
strategy is not appropriate as the request thread is not accessible from the test.It would be nice if
SQLStatementCountValidator
could support theSingleQueryCountHolder
strategy.The text was updated successfully, but these errors were encountered: