Why should I bother with unit testing if I can just use integration tests?
Posted
by CodeGrue
on Stack Overflow
See other posts from Stack Overflow
or by CodeGrue
Published on 2010-04-09T17:59:43Z
Indexed on
2010/04/09
18:03 UTC
Read the original article
Hit count: 382
unit-testing
|time-wasters
Ok, I know I am going out on a limb making a statement like that, so my question is for everyone to convince me I am wrong. Take this scenario:
I have method A, which calls method B, and they are in different layers.
So I unit test B, which delivers null as a result. So I test that null is returned, and the unit test passes. Nice.
Then I unit test A, which expects an empty string to be returned from B. So I mock the layer B is in, an empty string is return, the test passes. Nice again. (Assume I don't realize the relationship of A and B, or that maybe two differente people are building these methods)
My concern is that we don't find the real problem until we test A and B togther, i.e. Integration Testing. Since an integration test provides coverage over the unit test area, it seems like a waste of effort to build all these unit tests that really don't tell us anything (or very much) meaningful.
Why am I wrong?
© Stack Overflow or respective owner