May 18th, 2006, 02:12 AM
Help in testing
Hello, reading documentation of Spring, i have read a point that says:
"As the leading full-stack Java/J2EE application framework, Spring delivers significant benefits for many projects, reducing development effort and costs while improving test coverage and quality."
Reducing development is obviously because no singleton or factories have to be implemented, also IoC, integration of hibernate, ... but can anybody explain me how is possible to improve test coverage and quality?
Thank you very much.
May 18th, 2006, 03:13 AM
well, the product quality increases, 'cos the ammount of code to be tested goes down That gives you an oportunity to focus only on testing of your business code.
May 18th, 2006, 04:09 AM
There are a couple of *excellent* threads on this subject, but I can only find one of them...http://forum.springframework.org/sho...t+test+benefit
Originally Posted by mag_gandalf
Anyway, in summary unit tests are improved because IoC prevents (too strong a word but...) classes instantiating their own classes, rather they are passed in. Classes also work against interfaces, not implementations.
This allows you to unit test that class by providing mock implementations.
Assume classA requires an implementation of dao to do some work, previously you might have had classA do jndi.lookup("dao"), which would have made classA impossible (or very difficult) to unit test. Now, when you construct classA you provide the dao, so when you want to unit test you can very easily provide a mock dao.
As a result your classes tend to become smaller and focused on a single thing, thus making them easier to unit test.
To be clear; IoC doesn't *force* you to unit test, but a side effect of using IoC makes them easier.
I wish I could find that other thread