
Thanks: 0
Likes: 0
Dislikes: 0

Junior Member
please help me for this question..
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?
please explain in brief...

Member
Re: please help me for this question..
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.

Moderator
Re: please help me for this question..
How many tests have you thought of so far and what are they?
Please help us to help you by indicating how far you can get by yourself.
And, for future reference, please make your Subject more descriptive of what's in your post.

Member
Re: please help me for this question..
I have nothing to declare except my genius. Oscar Wilde

Moderator
Re: please help me for this question..
And your 3 cases are?
It seems to me you may have missed something.

Member
Re: please help me for this question..
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.
I have nothing to declare except my genius. Oscar Wilde

Moderator
Re: please help me for this question..
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

Member
Re: please help me for this question..
As far as I know, there are 3 statements.
1> x=3
2> y=2
3> 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.
I have nothing to declare except my genius. Oscar Wilde

Member
Re: please help me for this question..
[ QUOTE ]
how many tests are required for 100% statement, branch coverage?
please explain in brief...
[/ QUOTE ]
Draw a flow diagram, once you have that you can see the different paths through the code and it's pretty straightforward.

Apprentice
Re: please help me for this question..
As far as I understood If statements are taken up... Then it seems to me 5 test cases are required:
1) x<3, yany, ouput: z
2) x=3, y<2, output: x, z
3) x=3, y=2, output: x, y
4) x=3, y>2, output: x, z
5) x>3, yany, output: z
Another variant:
1) x!=3, yany, 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 <>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules
