Statement and Branch Coverage

Hi All,

Pls let me know the statement coverage and branch coverage for the below code.

Read P
Read Q
IF P+Q > 100 THEN
Print “Large”
ENDIF
If P > 50 THEN
Print “P Large”
ENDIF


Regards,
Vidhya

Questions by vidhya.sadasivam

Showing Answers 1 - 18 of 18 Answers

Hi All,
In the above mentioned script Statement  Coverage means all the statement has been covered or not and Branch Coverage means all the Conditions has been covered or not.

So for statement coverage we need to test the statement
-Print “Large”n
-
Print “P Large”
has been executed or not.

For Branch coverage(Condition coverage) we have to check the condition by passing some value and cheking all the conditions (true/false) are executed or not
-      P+Q > 100
-      P > 50


Please make me understand if i am wrong.

Thanks, Jitu

Coverage is nothing but degree expressed as a percentage to which a specific coverage item has been exercised by a set of tests.

Branch is nothing but conditional transfer of a control from any other statement to other statement.
Here the condition is transftered from the first statement to second statement.

  Was this answer useful?  Yes

Statement Coverage:

                            Percentage of statements covered in a code is known as statement coverage.

Branch Coverage:
                          Percentage of branches covered in a code

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions