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 1 Question 20 Discussion

Actual exam question for ISTQB's ISTQB-CTFL exam
Question #: 20
Topic #: 1
[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:

Alaine
6 months ago
Makes sense, 4 tests cover all paths.
upvoted 0 times
...
Stephaine
6 months ago
We need one test for each condition: boy and girl, and age brackets.
upvoted 0 times
...
Shannon
6 months ago
Why 4?
upvoted 0 times
...
Stephaine
6 months ago
I think the answer is B) 4.
upvoted 0 times
...
Mammie
7 months ago
Yeah, it's a bit complicated.
upvoted 0 times
...
Blossom
7 months ago
This question seems tricky.
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