The Importance of Being Testable

Designing and building for testability in software at all levels (functional and unit testing) is one of those things most people don’t get. When I first started out in software I remember getting stuck with a last minute task of creating a web client for a test team who needed to test a XML web service. At the time I cursed the task and didn’t really think there was much value in creating the test client. Now though I try and put testing hooks like that all over the place. After looking back at software systems I have designed or worked on, I have realized that one of the main things that people have cursed or praised code on is testability.

Why Testability is Important?

Every developer has their own style for design and coding and some of them are going to think anything else is basically wrong, even if it works. So trying to win people over with coding style or awesome design is a losing battle. The central concept to all good code and systems though regardless of style or design is being able to validate if it works (aka testability). The more you can isolate each part of the system into individual testable parts the easier it becomes for people to feel confident in making changes. Which is ultimately what it’s all about. If someone can come into a system they have never worked on before, make a change, and feel confident about the change, they can’t get too upset.

Designing for Testability

Testability is all about isolation. If you are creating a system with dependencies on another system you need to be able to eliminate the need for that other system for testing. There will be scenarios where you don’t want to have the dependency whether it’s during a unit test or you don’t have access to that system in certain testing environments. Solutions for this could involve the ability to configure different end points at run time and/or putting proxies in front of calls to intercept and return mock responses. The same goes for code, you need to be able to isolate units of code and make them fail or pass tests only if that code is broken. This will involve using factory patterns, dependency injection, and/or other loose coupling strategies.

All Systems Must be End User Testable

Even if your developing a service which operates over an obscure protocol with proprietary message format, there is no excuse for not having a test interface available to allow non-developers to test the functionality. In many cases this means creating a test program or test interface on a system. This may not be in the requirements however it should be. It’s left out many times because they are written in the context of an integrating system which drives testing. Unfortunately the integrating system may or may not be available in all environments and also there could be bugs in the integrating system requiring alternate testing interfaces to validate your system which should validate the need for a end user test interfaces. One of the main places you’ll find integrated systems missing is working locally as a developer. All these aspects of testing make it desirable to get end user testability in what you are developing and it will help people down the line as well.

Advertisements

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: