Statement, Branch/Decision and Path Coverage

An entity like a line of very simple code is called a “statement“, ie. in Java:

String greeting = "Hello World!";

Wheather it has a functionality, a usecase or it is executable or not, It has been declared / stated in the code. So as testrers, our focus is the ones that we can verify their executions. we need to follow a technical process to cover these executable statements. Test their presence, function etc. The goal of a “Statement Coverage” is to run all the “Executable Statements” for once. ie. for above code, “Hello World!” text might have been printed in the console and when we assert that, we have successfully covered this statement. ­čÖé Practical, isn’t it! This is also called “White / Open box testing” Becausse source code package is lighed / opened to the tester. /* You can read more about Open Box Testing here. */

To prepare a report on statement coverage, we first determine the total number of statements in the application (we will call it “S“) and find the number of executed statements (we can call it “E” as well) then our report will include this formula: Statement Coverage = E/S*100

Be careful about the asssumption that “statement coverage covers all functionalities.. ” it is false. It does not cover all conditions, covers only the true conditions.!

Aix Observer
Aix Observer
Articles: 30

Leave a Reply

Your email address will not be published. Required fields are marked *