ExamGecko
Question list
Search
Search

Related questions











Question 90 - CTFL-2018 discussion

Report
Export

Consider the following pseudo code

1. Begin

2. Read Gender

3. __Print ''Dear''

4. If Gender = 'female'

5. Print (''Ms'')

6. Else

7. __Print ( ''Mr'')

8. Endif

9. End

How many test cases are needed to achieve 100 per cent decision coverage?

A.
1
Answers
A.
1
B.
2
Answers
B.
2
C.
3
Answers
C.
3
D.
4
Answers
D.
4
Suggested answer: B

Explanation:

Decision coverage is a structure-based test technique that involves testing every decision point in the code by testing all possible outcomes or branches of each decision point. Decision coverage requires some knowledge of the internal structure or implementation of the software system; it focuses on how the system does what it does rather than what it does.

The pseudo code given in the question has one decision point at line 4, where the value of Gender is compared to 'female'. This decision point has two possible outcomes or branches:

True branch: If Gender = 'female', then print ''Ms'' at line 5.

False branch: If Gender != 'female', then print ''Mr'' at line 7.

To achieve 100 per cent decision coverage, we need to test both outcomes or branches of the decision point at least once. Therefore, we need two test cases that cover both scenarios:

TC1: Gender = 'female' -> Print ''Dear Ms''

TC2: Gender = 'male' -> Print ''Dear Mr''

The other options are not correct because they do not provide enough or too many test cases to achieve 100 per cent decision coverage. For example:

A: 1: This option is not enough because it only provides one test case that covers one outcome or branch of the decision point, but not the other.

C: 3: This option is too many because it provides three test cases that cover both outcomes or branches of the decision point, but one of them is redundant or unnecessary.

D: 4: This option is too many because it provides four test cases that cover both outcomes or branches of the decision point, but two of them are redundant or unnecessary.

You can find more information about decision coverage and structure-based testing in [A Study Guide to the ISTQB Foundation Level 2018 Syllabus], Chapter 4, Section 4.3.

asked 18/09/2024
Kinzonji Tavares
42 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first