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
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.
Odette
4 months agoSherita
4 months agoAleisha
4 months agoLindsay
4 months agoLuisa
4 months agoFrankie
5 months agoNieves
3 months agoLaila
3 months agoRolande
3 months agoVeronique
4 months agoLaura
4 months agoFrancene
4 months agoGolda
4 months agoRickie
4 months agoKaron
4 months agoCarey
4 months agoKenneth
5 months agoWenona
5 months agoDierdre
5 months agoDorinda
5 months agoDerick
4 months agoSantos
4 months agoDarrel
4 months agoVerlene
5 months agoBulah
5 months ago