ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 25 - CTAL-TTA discussion

Report
Export

Consider the following section of pseudo code and associated test Input data:

If withdrawal-amount <= amount-on-deposit then Set authorize-transaction = true

Else

If withdrawal-amount <= S100 AND preferred-customer = true then Set authorize-transaction = true

Else

Set authorize-transaction = false

Endif

Endif

Input data set #1

withdrawal-amount = 160

amount-on-deposit = 100

preferred-customer = true

Input data set #2

withdrawal-amount = 500

amount-on-deposit = 500

preferred-customer = false

Input data set #3

withdrawal-amount = 50

amount-on-deposit = 500

preferred-customer = false

What would be the decision coverage achieved if each of these test input data sets were run once?

A.
100%
Answers
A.
100%
B.
50%
Answers
B.
50%
C.
0%
Answers
C.
0%
D.
33%
Answers
D.
33%
Suggested answer: A

Explanation:

To achieve decision coverage, each branch of the decision structure in the code must be executed at least once. The code snippet has three branches:

withdrawal-amount <= amount-on-deposit

withdrawal-amount <= $100 AND preferred-customer = true

Default case where the transaction is not authorized

Data set #1 triggers the second branch because the withdrawal amount is not less than the amount on deposit, but it is less than $100, and the user is a preferred customer.

Data set #2 triggers the first branch where the withdrawal amount is equal to the amount on deposit.

Data set #3 tests the condition where the withdrawal amount is less than the deposit amount, but the user is not a preferred customer, triggering the default case.

All decision branches are covered by these test cases, achieving 100% decision coverage.

asked 18/09/2024
Roberto Garavaglia
45 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first