Many a times I was asked about Code Coverage Analysis, what is it and how can we measure it? Through this blog I will try to address some of the basic queries about Code Coverage Analysis and its usefulness.
What is Code Coverage?
Code Coverage Analysis is simply a structural testing technique to measure how many lines/blocks/arcs of your implemented code are executed while the automated tests are running. Its analysis gives you a quick, automated and accurate quality & coverage measurement for test plans. It helps a product team identify areas where additional test cases need to be added in a scientific and quantitative manner. Sometimes it is also termed as “Test Coverage”. This technique is typically used to take product quality to the next level. Just to explain things better, if you have 90% code coverage then it means that 10% of your code is not covered under tests. Although 90% looks a very convincing percentage but this 10% of the code can affect your product quality severely, especially when the number of lines of code is large.
Code Coverage Metrics
Measuring your code coverage is very important. Companies believe they have good code coverage in QA, without having any quantitative evidence to support it. However there are number of metrics through which you can determine, how well your codes are exercised. Some of the key metrics are listed below:
Statement Coverage: It is the most basic form of code coverage. This gives an indication of the number of statements (lines) that are covered in the simulation. This has to be 100% for every project.
- Block Coverage: A group of statement which has a beginning and end like if-else loop or while loop or for loop is called block. This metric gives an indication whether these blocks are covered in the testing or not
- Condition/Expressions Coverage: Codes typically contain variable and expressions (with logical operators) in conditional statements. Condition coverage gives an indication of how well these variables are evaluated
- Branch/Decision Coverage: In this coverage if-else conditions are evaluated in both true and false cases
- Toggle Coverage: This metric report how many times signals and ports are toggled during a simulation run
Tools:
There are number of tools available which will enable you to measure the Code Coverage of implemented codes. Please refer this link to know more about them.
Limitations of Code Coverage:
Code Coverage will never tell you anything about the design code and what it is supposed to do. It is just an indication to understand how well the design code has been executed. There is no way to find through code coverage that what is missing in your code, as it can only tell you the quality of the code implemented.
Calsoft has done code coverage analysis for many customers and has helped many storage product teams improve the quality of the product significantly. Calsoft has experience to do not only user mode application code coverage but also for kernel components/modules.
To know more email: marketing@calsoftinc.com
Anupam Bhide | Calsoft Inc.