I am thinking, if I do proper testing for all methods in all my classes, then - disrgegarding UI - do I still need system testing? I mean, what would a simple example be, showing a case where unit testing is not necessary to reveal some errors? I tried to come up with something but failed, it always could have been caught at unit level.
Asked
Active
Viewed 413 times
1
-
see [Why do 'some examples' and 'list of things' questions get closed?](https://softwareengineering.meta.stackexchange.com/a/7538/31260) – gnat Apr 25 '18 at 15:57
-
see also: [Unit Tests work but there are still bugs?](https://softwareengineering.stackexchange.com/a/206973/31260) – gnat Apr 25 '18 at 16:00
-
See: https://i.pinimg.com/originals/69/eb/29/69eb293ffb2d1166cbaed9be4dd3d348.gif or https://imgur.com/gallery/rrAxO – Eternal21 Apr 25 '18 at 18:03
-
1Possible duplicate of [Unit Tests work but there are still bugs?](https://softwareengineering.stackexchange.com/questions/206967/unit-tests-work-but-there-are-still-bugs) – Doc Brown Apr 25 '18 at 19:35
-
So I had this interesting bug that required three phones to reproduce... – gnasher729 Apr 25 '18 at 19:46
2 Answers
3
Think of it this way:
- Unit tests validate implementation
- Integration tests validate design
- Behaviors (BDD) validate specifications
You can have your one unit tested to 100% coverage documenting at least one reason for every line and branch you have in that unit. Then you combine that unit with something else that had different expectations for how your unit behaves. Behold an error in the design.

Berin Loritsch
- 45,784
- 7
- 87
- 160
-
1I upvoted this, even though I disagree with your bullet 2, because your answer provides clarity. But Wikipedia disputes your definition of "system testing," and not all shops use BDD. – Robert Harvey Apr 25 '18 at 17:16
-
I'm well aware that not all shops use BDD, but that is it's purpose. I think I wrote System tests when I meant to write _Integration_ tests. I will change the working to indicate that. – Berin Loritsch Apr 25 '18 at 19:24
1
Any interaction between the 'Units' of your unit test cannot be tested, whatever you choose as 'Unit'.
Imagine you are building a car, and you unit-test the engine and the wheels (and they pass). You now have a well-working engine, and well-working wheels.
If you now mount the engine on the outside of one wheel, your car will probably fail - because the issue is in the interaction between the units.
That's why there are integration tests.

Aganju
- 1,453
- 13
- 15
-
Well, if I test properly all the inputs and outputs of individual units (i.e. their interface), then the interaction of units should be easy as it uses them. – John V Apr 25 '18 at 16:45
-
The short answer is "No - it isn't easy". You make assumptions about "test properly", and that is well-known to be erroneous. If your wheels are rated for a particular horsepower, but the interface to the wheels does not specify the maximum horsepower, it is easy to build a non-working system by adding an overpowered engine. – BobDalgleish Apr 25 '18 at 16:52