In Statement Coverage testing the code is executed in such a manner that every statement of the application is executed at least once. It helps in assuring that all the statements execute without any side effect.This method is also called as line coverage or segment coverage. It is one of the testing coming under white box testing.See the Pdf tutorials about Statement Coverage.
In statement coverage testing we make sure that all of our code blocks are executed. We can also identify which blocks are failed to execute in this method.
Still bugs may be there after executing all the blocks without any failure. Because it wont check with all the conditions in a single block. Its only a basic testing after the complete coding and dynamic analysis. For checking with every conditions we need to to branch and path coverage testing.
What is Statement Coverage
Statement coverage represents a specific coverage criterion of white box testing. And it is characterized by 2 aspects:
- Which are the best test requirements for the criteria?
- How you measure the coverage for this criteria?
When it comes to statement coverage these test requirements are all the statements in the program. So, this is the basic and the simplest coverage criteria in the white box testing. And, as you know, white box testing is based on the assumption that if there isn’t a faulty element in the code, you need to execute it in order to find the faulty. And that’s exactly what statement coverage does.
The Ratio
A good measure of how well you exercise the code is the ratio of the number of executed statements. So, all the statements that your test cases execute to the total number of statements in the program.
The higher this number, the better you exercise your code.
Also, another way to look at this coverage criterion is in terms of questions. So, what is the question they were trying to answer when you look at a specific set of test cases and you assess the statement coverage that they achieved? It is whether each statement in the program has been executed. So, the statement coverage is satisfied when all the statements in the program have been executed.
And you can satisfy it to different degrees and the degrees to which it’s satisfied is measured by this value.
How statement coverage is used in practice?
Statement coverage is the most used kind of coverage criterion in industry. Normally for a company that uses statement coverage the typical coverage target is 80-90%, which means the outcome of the test should be such that 80-90% of the statements are exercised at the end of the testing.
There are several free tools available for conducting statement coverage testing.