Quality Testing

Quality is delighting customers

Can any one give the formula to calculate Statement Coverage

formula to calculate Statement Coverage

Views: 1040

Reply to This

Replies to This Discussion

Statement coverage identifies which statements in a method or class have been executed. It is a simple metric to calculate, and a number of open source products exist that measure this level of coverage. Ultimately, the benefit of statement coverage is its ability to identify which blocks of code have not been executed. The problem with statement coverage, however, is that it does not identify bugs that arise from the control flow constructs in your source code, such as compound conditions or consecutive switch labels. This means that you easily can get 100 percent coverage and still have glaring, uncaught bugs.

The following example demonstrates this. Here, the returnInput() method is made up of seven statements and has a simple requirement: its output should equal its input.

There's an obvious bug in returnInput(). If the first or second decision evaluates true and the other evaluates false, the return value will not equal the method's input. An astute software developer will notice this right away, but the statement coverage report shows 100 percent coverage. If a manager sees 100 percent coverage, he or she may get a false sense of security, decide that testing is complete, and release the buggy code into production.

Recognizing that statement coverage may not fit the bill, the developer decides to move on to a better testing technique: branch coverage.
Hi ,

The formula for calculating the statement coverage is

Statement Coverage= (Number of Statements Exercised / Total number of Statements) X 100 %

Similarly you can find the Decision Coverage

Decision Coverage = (Number of Decision outcomes Exercised / Total number of Decision outcomes) X 100%

Regards ,
Bal Krishna

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service