Vous êtes sur la page 1sur 6

ISCG6413 Testing and Quality Assurance in IT

Exercises

Exercise 1:

Below is a decision table for daily activities. Fill in the rules with true and false, and which action
should be taken

Conditions R R R3 R R R R R
1 2 4 5 6 7 8
A weekday is chosen T T T T F F F F
A holiday is chosen T T F F T T F F
Weather raining is T F T F T F T F
chosen
Actions
Go to work X X
Go on a picnic X
Stay home X
Error MESSAGE X X X X

Conditions R1, R3,4 R5 R6 R7, 8


2
A weekday is T T F F F
chosen
A holiday is T F T T F
chosen
Weather raining x x T F x
is chosen
Actions
RESULTS Err Go to Stay Go on Err msg
ms work hom a
g e picnic

Exercise 2:

Below is a decision table for reservation of meeting room. Fill in the rules with true and false, and
which action
Page 1 of 6
ISCG6413 Testing and Quality Assurance in IT

Conditions R R R3 R R R R R
1 2 4 5 6 7 8
No. of participants <= T T T T F F F F
capacity has entered
A free room is chosen T T F F T T F F
A valid Account no. has T F T F T F T F
entered
Actions
Msg: No room of the right X X X
size available
Exercise 3:

Msg: Room already booked X X X


A form with two fields
Msg: Account no. not valid X X X X of drop down items:
Book room X Field 1: The Employee
Type. Takes values:
Salary Based Hourly Based
Field 2: The Hours Worked: <40, 40, >40
The action for payment will be as follows:
- For employee based on salary, the payment will be only the salary regardless of the
number of hours
- For employee based on hourly:
o If working the 40 hours, the payment will be calculated according to the hourly
wages
o If working less than 40 hours, the payment will be calculated according to the hourly
wages and produce a report for the missing hours
o If working more than 40 hours, the payment will be calculated according to the hourly
wages up to 40 hours, and as overtime for hours above 40.

Create the decision table.


Note: As we have 5 conditions, to put all of them in one table we need 32 rules try to create
several tables with fewer conditions then combine these tables in one simplified decision table

Conditions R1 R2 R3 R R R R R R9 R10 11 12 13 14 15 16
4 5 6 7 8
Salary based T T T T T T T T F F F F F F F F
40 T T T T F F F F T T T T F F F F
<40 T T F F T T F F T T F F T T F F
>40 T F T F T F T F T F T F T F T F

Page 2 of 6
ISCG6413 Testing and Quality Assurance in IT

Actions
PAYment by x x x
salary

Conditions R1 R2 R3 R R R R R R9 R10 11 12 13 14 15 16
4 5 6 7 8
Hourly based T T T T T T T T F F F F F F F F
40 T T T T F F F F T T T T F F F F
<40 T T F F T T F F T T F F T T F F
>40 T F T F T F T F T F T F T F T F
Actions
PAYment by x x x
wages
Produce x
absence
report
Pay overtime x

Conditions R1 R2 R3 R R5 R6
4
Employee S S S H H H
Type
Conditions R1 R R5 R6
Hours 40 <40
4 >4 4 <4 >4
0 0 0 0
Employee S H H H
Actions
Type
Pay by salary
Hours X
X X
4 <4 X >4
PAYment by 0 0 0 X X X
wages
Actions
Produce
Pay by salary X X
absence
PAYment by X X X
report
wages
Pay overtime X
Produce X
absence Page 3 of 6
report
Pay overtime X
ISCG6413 Testing and Quality Assurance in IT

Exercise 4:

If you are flying with an economy ticket, there is a possibility that you may get upgraded to
business class, especially if you hold a gold card in the airline's frequent flier program. If you don't
hold a gold card, there is a possibility that you will get 'bumped' off the flight if it is full and you
check in late. This is shown in the Figure below. Note that each box (i.e. statement) has been
numbered.

Three tests have been run:


Test 1: Gold card holder who gets upgraded to business class
Test 2: Non-gold card holder who stays in economy
Test 3: A person who is bumped from the flight

What is the statement coverage of each individual test?


What is the statement coverage of these three tests combined together?

No. of statements: 10
Test 1 statements: 1, 2, 4, 5 coverage: 4/10 = 40%
Test 2 statements: 1, 6, 7, 5 coverage: 4/10 = 40%
Test 3 statements: 1, 6, 8, 10 coverage: 4/10 = 40%
Overall statements covered: 1, 2, 4, 5, 6, 7, 8,10 coverage: 8/10 = 80%

Exercise 5:

Given the state diagram in the Figure below.


What is the test case that gives the minimum series to test all the transitions

Page 4 of 6
ISCG6413 Testing and Quality Assurance in IT

What is the test case that gives the minimum series to test all the states

To test all the states: SS S1 S2 S4 S1 S3 - ES


To test all the transitions: SS S1 - S2 S4 S1 S3 S4 S1 S3 - ES

Exercise 6:

Decision table exercise


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. You can only hold one type of rail card.
Produce a decision table showing all the combinations of fare types and resulting discounts and
derive test cases from the decision table.

Conditions R1 R2 R3 R4 R5 R6 R R
7 8
Over 60s T T T T F F F F
Travel with T T F F T T F F
Conditions
a child R1, 5 R2 R3, R6 R7,
4 8
Hold family T F T F T F T F
Over
card 60s X T T F F
(don
Actions
t
DISCOUNT 50%
care) 34% 34 34 50 10 0 0
% % % %
Travel with T T F T F
a child
Hold family T F X F X
card
Actions Page 5 of 6
DISCOUNT 50% 34% 34% 10 0
%
ISCG6413 Testing and Quality Assurance in IT

Exercise 7:

State transition exercise


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 check out, 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.
b. Define a test, in terms of the sequence of states, to cover all transitions.
c. Produce a state table. Give an example test for an invalid transition.

Exercise 8:

Statement and decision testing exercise


A vending machine dispenses either hot or cold drinks. If you choose a hot drink (e.g. tea or
coffee), it asks if you want milk (and adds milk if required), then it asks if you want sugar (and adds
sugar if required), then your drink is dispensed.
a. Draw a control flow diagram for this example. (Hint: regard the selection of the type of drink as
one statement.)
b. Given the following tests, what is the statement coverage achieved? What is the decision
coverage achieved?
Test 1: Cold drink
Test 2: Hot drink with milk and sugar
c. What additional tests would be needed to achieve 100% statement coverage? What additional
tests would be needed to achieve 100% decision coverage?

Page 6 of 6