User Tag List

Thanks:  0
Likes:  0
Dislikes:  0

If x=3
display x;
if y=2
display y;
else
display z;
else
display z;

how many tests are required for 100% statement, branch coverage?

you can make test case for upper value of x ie greater then 3
one lower and one exact 3 . i am assuming positive values.
if first condition is filled the no other case will excute. i mean x=3.

if x has other value and y = 2
then result will y. but make sure upper and lower limit does not show the value y.

in all other cases it will display z.

How many tests have you thought of so far and what are they?

3 cases

It seems to me you may have missed something.

IF input is 3 then it will print x
IF input is 2 then it will print y
IF input is something other than 2 and 3 then it will print z.

So what if x=2 and y=3?
x=2 and y = 4?
x=4 and y=3?
x=4 and y=4?
x=2.00000000000000000000001?
y=2.999999999999999999999999?

etc

As far as I know, there are 3 statements.
1&gt; x=3
2&gt; y=2
3&gt; z

to cover these 3 statments, 3 cases are required.
If x=3 then print x
if y=2 then print y
if nothing of above then print z

correct if I am wrong.

[ QUOTE ]

how many tests are required for 100% statement, branch coverage?

[/ QUOTE ]

Draw a flow diagram, once you have that you can see the different paths through the code and it's pretty straightforward.

As far as I understood If statements are taken up... Then it seems to me 5 test cases are required:
1) x&lt;3, y-any, ouput: z
2) x=3, y&lt;2, output: x, z
3) x=3, y=2, output: x, y
4) x=3, y&gt;2, output: x, z
5) x&gt;3, y-any, output: z

Another variant:
1) x!=3, y-any, output: z
2) x=3, y!=2, output: x, z
3) x=3, y=2, output: x, y
Then only 3 test cases are required. It's a debatable question use != or split it into 2 cases &lt;&gt;

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.