Disciplined Agile

Core Developer Skills: Testability

Testing and testability are related, but not the same thing. When attempting to test a part of the system, if it seems to be difficult to test, this can be an indicator of poor design.


Attempting to test code offers numerous kinds of design-feedback:

  • If code is tightly coupled, then testing a single behavior of the system will require bringing up other parts of the system that are not related to the behavior but simple must be in place due to the coupling.
  • If code lacks cohesion, then the multiple responsibilities will need to be tested together, producing tests that can fail for multiple reasons.
  • If there is insufficient encapsulation in the system, then numerous negative scenarios will have to be tested. Issues which, with proper encapsulation, would be impossible for the system to have and therefore would not have to be teste for.
  • A system that lacks focus is hard to test because individual behaviors are spread throughout the system, requiring excessive work to test them.
  • Redundant code creates redundant tests, which causes problems when tests must be maintained. 

Thus, testability is an indicator of poor code quality: Bad code is hard to test. Testability is also an indicator of poor design: Bad designs are hard to test.  

Because of this, it is wise to consider the testability of a proposed design or code element as early as possible help to avoid rework. 


The best way to ensure that code is testable and, therefore, high in quality is to use test-driven development (TDD). The reason that counts as an “obstacle” is because test-driven development is a hard discipline. We can’t just start doing it and have it be helpful. We have to put in the time to learn how to do it right.


The upside of a hard discipline is that making the investment will keep on paying dividends until retirement. Take the time to get good at TDD now and testability will cease to be an obstacle. 

May 2023