‘Code Coverage’ - How does it help in testing ?
The million dollar question which every Manager asks to testing teams is that ‘Whether they have executed all the test cases ? “. If you are a software test practitioner, you would be feeling really frustrated. How on earth, can you ever execute all the ‘Test Cases’ for a particular feature.
Well, there is no silver bullet but there is a way which you can use to get a good enough answer for the above question. Its called ‘Code Coverage’ analysis.
How does it work
There are certain software tools in the market which can be used to do ‘Code Coverage’. One of the popular software is ‘Bullseye’. The process is simple. While building binaries for your software program, configure ‘Bullseye’ with the IDE. When binaries are made, bullseye inserts some of its own signatures. This is called ‘Instrumentation’ of the code.
Once a binary has been instrumented, just exercise the features of the program. As you use the program, a ‘coverage’ file gets created and updated. This ‘coverage’ file has the information on the lines of code which are getting executed. After you are done, analyze this coverage file using Bullseye and you would get details on ‘how much code has been covered’. So if you run your whole test-suite then you would get the coverage for that test-suite.
How to interpret results
If you have a 100% coverage then something is wrong because then you are doing something which is so perfect. For a real life full blown software application, 100 % is not possible and not desirable as well. Code coverage reports helps you in two ways.
1. It helps you to find the ‘dead code’, the code which is never executed.
2. It helps you to find the areas within the code for which no testcase has been executed.
To keep it short, I would stop here but feel free to ask anything by writing a comment.
July 23rd, 2008 at 7:27 am
Nice article !!!
I have not used “Bullseye” tool but I did used Java Junit code coverage tool integrated with WSAD (Websphere Application Development IDE) sometime back. It is a good code coverage testing tool.
When integrated with build script you can create cruise control dashboard . You can track unit test code coverage for each java package in the code. It also points to the missing and dead code. I really liked it and just wanted to share my experience.
July 23rd, 2008 at 11:44 am
Thanks Manish.
Would you want to write a guest article about ‘Junit CC tool’ which you mentioned. It would be useful to fellow readers.
Thanks