Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

ISTQB Exam ISTQB-CTFL Topic 2 Question 24 Discussion

Actual exam question for ISTQB's ISTQB-Foundation Level Exam exam
Question #: 24
Topic #: 2
[All ISTQB-Foundation Level Exam Questions]

For the following pseudo-code determine number of tests required for 100% statement coverage

IF Gender = Boy

If Age > 3 AND Age < 5

Shoe Size = 1

ELSE IF Age >=5 AND Age < 7

Shoe Size = 2

ENDIF

ELSE

IF Age > 3 AND Age < 5

Shoe Size = 0

ELSE IF Age >=5 AND Age < 7

Shoe Size = 1

ENDIF

ENDIF

Show Suggested Answer Hide Answer
Suggested Answer: B

To achieve 100% statement coverage, we need to design test cases that ensure every statement in the given pseudo-code is executed at least once. Analyzing the pseudo-code, we notice that there are conditions based on two variables: Gender and Age. To cover all statements, we need to consider the paths that lead to each assignment of the Shoe Size variable.

Gender = Boy, Age <= 3 (Shoe Size assignment is not reached, but the condition is evaluated)

Gender = Boy, Age > 3 AND Age < 5 (Shoe Size = 1)

Gender = Boy, Age >= 5 AND Age < 7 (Shoe Size = 2)

Gender != Boy, Age <= 3 (Again, Shoe Size assignment is not reached, but the condition is evaluated)

Gender != Boy, Age > 3 AND Age < 5 (Shoe Size = 0)

Gender != Boy, Age >= 5 AND Age < 7 (Shoe Size = 1)

However, upon closer inspection, we see that tests 1 and 4 do not contribute to statement coverage as they do not lead to a Shoe Size assignment. Therefore, we only need 4 test cases to achieve 100% statement coverage, making option B the correct answer.


Contribute your Thoughts:

Odette
19 days ago
Haha, this reminds me of that time I had to test a program that calculated the age of a dog in 'dog years'. Who comes up with these ridiculous scenarios? Anyway, I'm going with B) 4.
upvoted 0 times
...
Sherita
23 days ago
Wait, is this a trick question? Shouldn't we just test all the possible combinations of gender and age? That would be 2 * 2 = 4 tests. I'm picking C) 2.
upvoted 0 times
Aleisha
9 days ago
I agree with you. We should test all the conditions to achieve 100% statement coverage. I'll go with D) 6.
upvoted 0 times
...
Lindsay
12 days ago
I think we need to consider all the conditions in the pseudo-code. So, it's not a trick question. I choose A) 6.
upvoted 0 times
...
...
Luisa
24 days ago
D) 6 makes the most sense to me. It's the same as the first option, and I'm pretty sure that's the right answer.
upvoted 0 times
...
Frankie
30 days ago
I'm going to go with A) 6 tests. The code has 6 distinct branches that need to be covered for 100% statement coverage.
upvoted 0 times
Laura
2 days ago
I think A) 6 tests is the correct answer. Each branch in the code needs to be tested for 100% statement coverage.
upvoted 0 times
...
Francene
2 days ago
I agree, there are 6 distinct branches in the code.
upvoted 0 times
...
Golda
7 days ago
Yes, testing all 6 branches is necessary to ensure that every statement is executed at least once.
upvoted 0 times
...
Rickie
7 days ago
I think it's A) 6 tests.
upvoted 0 times
...
Karon
16 days ago
I agree, we need to test each possible path in the code to achieve full statement coverage.
upvoted 0 times
...
Carey
21 days ago
I think A) 6 tests is the correct answer. Each branch in the code needs to be tested for 100% statement coverage.
upvoted 0 times
...
...
Kenneth
1 months ago
I believe the answer is B) 4, as we only need to cover the different conditions within the IF statements
upvoted 0 times
...
Wenona
1 months ago
I'm not sure, but I think it's either A) 6 or D) 6
upvoted 0 times
...
Dierdre
2 months ago
I agree with Bulah, because we need to cover all possible combinations of Gender and Age
upvoted 0 times
...
Dorinda
2 months ago
Hm, I think the answer is B) 4. There are 4 unique paths through the code based on the different combinations of gender and age.
upvoted 0 times
Derick
13 days ago
I'm not sure, but I think it's either A) 6 or B) 4. We need to carefully analyze the code.
upvoted 0 times
...
Santos
14 days ago
I see your point, but I still think it's B) 4. We just need to consider the unique paths.
upvoted 0 times
...
Darrel
27 days ago
I think it's actually A) 6. We need to cover all possible conditions in the code.
upvoted 0 times
...
Verlene
1 months ago
I agree, the answer is B) 4. Each unique path requires a test case.
upvoted 0 times
...
...
Bulah
2 months ago
I think the answer is A) 6
upvoted 0 times
...

Save Cancel