You are on page 1of 4

Decision Table (7 marks)

Scenario: If you hold an “over 60s” rail card, you get a 34% discount on whatever ticket
you buy. If you are traveling with a child (under 16), you can get a 50% discount on any
ticket if you hold a family rail card, otherwise you get a 10% discount.

o Produce a decision table showing all the combinations of fare types and
resulting discounts.
o Derive test cases from the decision table.

There are three conditions (fare types) in this situation.


• Over 60s rail card
• Family rail card
• Travelling with child
With three conditions, we have (2 to the power of conditions) eight combinations.

Conditions Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 8


Over 60s T T T T F F F F
rail card
Family rail T T F F T T F F
card
Travelling T F T F T F T F
with child
Actions
Discount 50 %/ 34 %/ 34 % 34 % 50 % 0% 10 % 0%
(%) X/ X/
? ?

The assumption made here is that a person cannot have more than one rail card, therefore
we placed “X” in the outcome for rule 1 & 2. Also, in the scenario, the discount is not
stated when a person has more than one rail card, therefore we placed “?”. If a person
does have two rail cards, they would claim 50 % discount if they are travelling with a
child using their family rail card and would claim 34 % using over 60s rail card if
travelling without a child.

The outcome of rule 3 & rule 4 yields the same outcome of 34% discount. This shows
whether the child is travelling or not, doesn’t have any effect on the outcome. Also, the
outcome of rule 6 & rule 8 are 0 % discount. This shows if the child is not travelling,
having a family rail card has no effect. Therefore, we can reduce the table which would
be based on the assumptions about the factors having no effect on the outcome.
Conditions Rule 1 Rule 2 Rule 3 Rule 5 Rule 6 Rule 7
Over 60s T T T F F F
rail card
Family rail T T F T - F
card
Travelling T F - T F T
with child
Actions
Discount 50 % 34 % 34 % 50 % 0% 10 %
(%)

This rationalized table has fewer columns and thus will result in fewer test cases.

Test case

Test Conditions Outcome


Case
1 A person who has over 60s rail & 50% discount will be given for both
family rail card and also traveling with tickets
child under 12
2 A person having over 60s rail card & 34% discount on the ticket
family rail card & is traveling alone
3 A person having over 60s rail card 34% discount given to the person
only & traveling with his friend having over 60s rail card & no
discount will be given to his friend.
4 A person having family rail card only 50% discount will be given for both
& traveling with child tickets
5 A person having no rail card & is No discount (0%)
traveling alone
6 A person having no rail card traveling 10% discount will be given for both
with child under 16. tickets

The assumption that we have taken in this scenario is that the discount is given to all
travelers, not just the holder of family rail card if they are traveling together. If the person
doesn’t have family rail card, but only have over 60s rail card & travelling with someone,
the discount will be given to the holder of the card only, not to other passenger traveling
with him.
Scenario: A website shopping basket starts out as empty. As purchases are selected, they
are added to the shopping basket. Items can also be removed from the shopping basket.
When the customer decides to checkout, a summary of the items in the basket and the
total cost are shown, for the customer to say whether this is OK or not. If the contents and
price are OK, then you leave the summary display and go to the payment system.
Otherwise you go back to shopping (so you can remove items if you want).

a. Produce a state diagram showing the different states and transitions. Define a test,
in terms of the sequence of states, to cover all transitions.
b. Produce a state table. Give an example test for an invalid transition.

In this scenario, there are 4 states:


• S1 – shopping basket is empty.
• S2 – items are placed or removed from shopping basket
• S3 – summary of items & total cost are displayed.
• S4 – payment system.

The starting state is when the shopping basket is empty (S1). As items are purchased, it
changes state and goes to shopping state (S2). When the customer adds more items, the
state doesn’t change, only the number of items in the shopping basket increases.
Customers can also remove items as well, which also doesn’t change the state. If all the
items are removed, then only the state will move to empty state (S1). When the customer
decides to checkout, the state changes to summary & cost state (S3). If the contents and
price are OK, the state will change to payment state (S4). If the customer is not happy
with the contents and price, the state will move back to shopping state (S2) and the
customers can make changes in the shopping basket, i.e. they can add or remove some
items.
Test to cover all transitions.

State Transitions
S1 Add item
S2 Remove last item
S1 Add item
S2 Add item
S2 Remove item
S2 Check out
S3 Not OK
S2 Check out
S3 OK
S4

State table

S1) empty S2) shopping S3) summary S4) payment


& cost
Add item S2 S2 - -
Remove item - S2 - -
Remove last item - S1 - -
Check out - S3 - -
Not OK - - S2 -
OK - - S4 -

Invalid transitions are the ones having ‘ - ’ (dash) in the state table. Some of the negative
state includes:
• Removing item from empty shopping basket (S1)
• Check out at empty shopping basket (S1)
• Adding item at summary & cost state (S3)
• Entering ‘OK’ at shopping state (S2)
• Adding item at payment state (S4)
• Removing item at summary & cost state (S3)

You might also like