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