Qualities Patterns Share: Testability

All software should ideally be tested. That said, some designs are more easily tested than others. This “testability” factor can be very useful in determining the quality of a given design, because:

  1. When a design is excessively coupled, then testing any class in it will require that many other parts of the system are created in the test. This can make tests complex to write and slow to run. The test will also fail for multiple reasons.
  2. When a class has multiple responsibilities (weak cohesion), then those responsibilities must be tested together. The tests become difficult to read, write, and maintain.
  3. When the system has redundancies, the tests will also because the same issues will have to be tested repeatedly.
  4. When encapsulation is weak, many side effects are possible, and thus tests must be written to guard against them. The test suite becomes many times larger than the production package or namespace.

Testability, therefore, is really the quality of all qualities because weakness in design always makes testing difficult and painful. Pain is, after all, nature's diagnostic tool. We feel pain in order to know that something is wrong.

The earlier that testability is considered, the earlier design flaws can be discovered and corrected.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset