Cyber Monday 2024! 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-CTFL exam
Question #: 24
Topic #: 2
[All ISTQB-CTFL 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
4 months 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
4 months 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
4 months 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
4 months 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
4 months 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
5 months 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
Nieves
3 months ago
Yes, testing all 6 branches is necessary to ensure that every statement is executed at least once.
upvoted 0 times
...
Laila
3 months ago
I agree, we need to test each possible path in the code to achieve full statement coverage.
upvoted 0 times
...
Rolande
3 months ago
That makes sense, let's go with A) 6 tests.
upvoted 0 times
...
Veronique
4 months ago
So, we need to test each branch to achieve 100% statement coverage.
upvoted 0 times
...
Laura
4 months 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
4 months ago
I agree, there are 6 distinct branches in the code.
upvoted 0 times
...
Golda
4 months ago
Yes, testing all 6 branches is necessary to ensure that every statement is executed at least once.
upvoted 0 times
...
Rickie
4 months ago
I think it's A) 6 tests.
upvoted 0 times
...
Karon
4 months ago
I agree, we need to test each possible path in the code to achieve full statement coverage.
upvoted 0 times
...
Carey
4 months 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
5 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
5 months ago
I'm not sure, but I think it's either A) 6 or D) 6
upvoted 0 times
...
Dierdre
5 months ago
I agree with Bulah, because we need to cover all possible combinations of Gender and Age
upvoted 0 times
...
Dorinda
5 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
4 months 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
4 months 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
4 months ago
I think it's actually A) 6. We need to cover all possible conditions in the code.
upvoted 0 times
...
Verlene
5 months ago
I agree, the answer is B) 4. Each unique path requires a test case.
upvoted 0 times
...
...
Bulah
5 months ago
I think the answer is A) 6
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77