There is life in Java without Spring. Who would have thought that possible ;)
Ever wondered if @springframework and #testing not always should go together? Check out my new post on @INNOQ blog: innoq.com/en/blog/springless…
2
9
1
17
I can’t remember any Java framework that has had more emphasis on user code being written in a way so that you can purely unit test it.
4
4
2
26
I can only second the statement by @olivergierke here
1
2
While that may well be true, I fail to see how the post suggests something different. Everyone seems to agree using Spring in unit tests is a bad idea. What am I missing?

Apr 27, 2018 · 5:20 PM UTC

3
1
Replying to @stilkov @bitboss
It starts with using Spring in a way that's know to be troublesome and that the Spring team discourages, as that style makes testing hard. It creates the impression that kind of design and testing approach is incentivized by the framework which it clearly is not.
4
8
Thank you. Interesting. I note every single Spring person I know reacted the same way. I wonder, though: Does this mean it’s not being used this way? Or that the post should have stated “don’t use it this way” in its intro?
4
2
That fully depends on what you are testing. 'real' unit tests make only sense for ~10 % of code in a business project. In those a good compromise btw quality and perf is testing with Spring or CDI and even the full DB layer (via e.g. in-memory DB) + Mocks for all 'boundaries'.
1
1
The post starts from wrong assumptions. I don’t see the reasoning from that example. „new Foo(mock(Bar.class))“ should be enough. Or passing a null or whatever. The general topic is just fine, I’d just wouldn’t start from that example. @jacek_bilski