mercredi 31 décembre 2014

With mock testing, are unit tests + system tests enough?

Before you jump to an answer, let's define what I mean (note that you may have different definitions, and that's part of the problem, but this is what I'm using)



mock testing aka behavior-based testing--- tests the code does the right thing i.e., tests verify behavior. All collaborators are mocked.


unit tests --- low-level tests focusing on a small part of the system (like a class). When we use mock testing, collaborators are mocked.


integration tests --- test the interaction of two or more parts of the system (like two classes). The components under test are not mocked.


system tests --- test the system as a "black box" i.e., from the perspective of a user who does not have access to the internals of the system. Real components are used (database, http, etc)



What I'm slowly realizing is that when unit tests are done this way, you may not need integration tests.



  • The behavior-based unit tests should verify that components talk to each other correctly

  • system tests should catch bugs from using real components


Integration tests then become an optional troubleshooting tool when a system test fails (since they're more fine-grained). (However, you might argue that system tests with good logging are enough except for the occasional edge case.)


What am I missing?


Aucun commentaire:

Enregistrer un commentaire