Testing & Instrumentation
Testing is very important. It’s the most widely used defect removal technique. An associated concept is Code Coverage, i-e your test cases should try to cover the most of the code; i-e if your code has 100 instruction; the test cases should be made so that all 100 instructions get executed (ideally)
However in some scenarios testing can be expensive. Few years back I developed an application for one of my company clients that send SMS and dial-out to specified numbers. Testing such applications is not practically easy.
Recently; I am asked to add couple of more features into the application. I had my unit tests; but I could not use them as I don’t have the required hardware with me anymore. I adopted Instrumentation approach.
With this; I setup a context and set a special attribute telling the API (which needs testing) to work in special mode. When that attribute is setup; the API doesn’t do the actual work; instead it simulate the behavior and logs the actions. This way my function signature remained same; i-e no change in my client code and test drivers; and I could test the new changes even in absence of actual hardware.
It took considerable time; but effort was worth it. I just have deployed the work; and its working flawlessly, and I am happy that I can join my wife at dinner.
My area of interest these days is how to improve maintenance cycles in application already in production. If anyone has related issues, please feel free to contact me.