Test Design using state transition diagrams Lab exercise
Black Box Tests – Part II
Designing test cases using State Transition Diagrams
Student names _______________________ and ______________________________
Contents
Q1 (2.5 pts) Draw a state transition diagram for a reservation or booking record..................................................3
Q2.a ) List the type of objects that have changing state (1 pts)...............................................................................7
Q2. b) Draw state diagrams for each of the object types you identified above. (2.5 pts)........................................8
Q2.c) Identify criteria and define a test case to verify correct handling for four different state transitions. For
example, two test cases are listed here. Add four more (1 pts each). (4 pts)...........................................................9
Page 1 of 10
Test Design using state transition diagrams Lab exercise
Instructions
Work in pairs – groups of two – and discuss (create a private chat) with each other as you complete the
exercise.
Marking
This assignment is marked out of 10. It has 2 questions.
Question one requires just one diagram is worth 2.5.
Question two requires a set of diagrams and four test cases. It is marks out of 7.5.
Due
Submit in eCentennial your joint solution before next Monday’s class.
Question 1 (2.5 pts)
You own a small resort of summer cottages and ask a local software developer to create a reservation system
you can use to manage bookings. Before accepting the software you test it thoroughly.
You have 20 cottages that you
refer to as #1, #2 … #20 and
operate the resort for 12 weeks
over the months of June, July and
August.
Weekly rental for each cottage is
$1000 per week. The rental
period is from noon on a Sunday
to noon on the following
Saturday. You clean and prepare
for the next customer each
Saturday afternoon and Sunday
morning.
Assume all customers stay one
week.
For each of the 20 cottages and
each of the 12 weeks, the use cases may occur.
Big hint: the states of a reservation are shown in bold.
Use cases:
To start, the reservation system marks all cottages as available for all weeks.
Customers may contact you by phone or email to ask about availability, prices and the like.
Page 2 of 10
Test Design using state transition diagrams Lab exercise
1. The system lets you add information about potential customers to your mailing list.
A customer contacts you by phone or email to reserve a cottage or a certain week.
o If the requested cottage and/or week are not available, you suggest alternatives.
o When you and the customer agree on a cottage and week, and the system lets you indicate that the
cottage is reserved.
Upon reserving, the customer must send you a deposit of $250 if the arrival date is more three weeks
ahead.
o If the deposit arrives within seven days, the cottage is marked as booked.
o If the deposit does not arrive within seven days, the system cancels the reservation and the cottage
becomes available for rental to another customer.
Full payment is due three weeks before the arrival date. That means a customer who reserved with a
deposit of $250 must pay the balance of $750 at least 21 days before arriving. A customer who books
late (less than 21 days before arriving) must pay the full amount of $1000 within seven days of
reserving.
o When the balance of rental payment arrives, the system lets you mark the cottage as rented.
o If the balance of rental payment does not arrive 21 days before the arrival date:
The system cancels the booking and the cottage becomes available.
You keep the deposit (if the customer paid it).
A customer may cancel a reservation or booking.
o The system lets you indicate the cottage is available again.
o If the customer cancels more than 3 months (90 days) before the arrival date, you return all money
paid - deposit and balance of payment (if paid).
o If the customer cancels between 3 months and 3 weeks of the arrival date (89-21 days) you keep the
deposit and return the balance of payment (if paid).
o If the customer cancels within 20 days of the arrival date, you keep all money paid.
On the arrival date, the cottage becomes occupied.
o If the customer does not turn up, you honour the booking anyway, in case the customer arrives late.
Q1 (2.5 pts) Draw a state transition diagram for a reservation or booking record.
Consider that the diagram is the same for all 20 cottages and all 12 weeks, but shows the state of a booking for
one cottage and one week.
Hint: Include only use case details that relate to a change of state.
Diagram
Page 3 of 10
Test Design using state transition diagrams Lab exercise
Reservation
Booking
Page 4 of 10
Test Design using state transition diagrams Lab exercise
Question 2 (7.5 pts)
CC Video store rents movies. You are testing the IT system that maintains the inventory of movies, customers,
rentals and reservations.
CC Video rents movies by the day, for a fee of $5. All rentals are for one day and the customer pays before
taking the movie out of the shop.
Returns are due by 6 pm on the next day. Customers return movies by handing the rented copy to staff or
dropping it into in a return box. The late fee is $6.00 for every day or part day overdue. Except for high demand
movies, the store usually waves the fee for returns just a few hours late.
All customers are members. Joining is free, but involves showing ID. The IT system assigns a member number
and then uses member number together with last name and phone number to verify identity. All members in
good standing (with no unpaid fines) can rent movies.
Members can also reserve movies to be picked after 6 pm on the same day. The store must keep enough copies
on reserve to satisfy all reservations.
Use Cases / Requirements
A. A member rents a movie with no reservation. Staff do the following:
Validate that the customer is a member
Check for outstanding fines. The member must pay all fines before renting.
Check that a copy is in stock and available for rental.
Take payment and give the member a copy of the movie.
Add a loan record to the system.
B. A member returns a movie Staff do the following:
Check whether the return is late.
o If the return is late and the customer is present, waive the fine or make the member pay.
o If the return is late and the customer is not present, use the system to add the fine to the
member’s record.
Remove the loan record from the system.
Return the copy of the movie to available stock.
C. A member reserves a movie. Staff do the following:
Validate that the customer is a member.
Check that an unreserved copy is in stock.
Record that a copy of the movie is reserved. If two or more members reserve the same movie, the store
must put more than one copy on reserve.
Page 5 of 10
Test Design using state transition diagrams Lab exercise
Page 6 of 10
Test Design using state transition diagrams Lab exercise
D. A member rents (collects) a reserved movie. Staff do the following:
Validate that the customer is a member who made the reservation.
Check for outstanding fines. The member must pay all fines before renting.
Check that a copy is in stock.
o If a copy is in stock and reserved by this member, clear the reservation record.
o If there is no copy in stock but one is reserved by this member, apologize to the member and note
a glitch in the system.
Take payment and give the member a copy of the movie.
Add a loan record to the system.
E. A Member cancels a reservation. Staff do the following:
Validate that the customer is a member who made the reservation.
Locate the reservation record and clear it
F. Automatic system action:
At the end of each business day, the system checks for reservations for that day that were not converted to
rentals and automatically clears them.
Instructions
Complete the following about changes in state that occur while this application is running.
Hints:
Make up a database schema (in reality you would probably ask the developers):
What database tables are required for the application?
When are rows added or deleted and what columns in those tables change as the use case
scenarios unfold?
Q2.a ) List the type of objects that have changing state (1 pts)
1.
Member: Represents a member of the CC Video store.
2. Movie Copy: Represents a physical copy of a movie.
3. Reservation: Represents a reservation made by a member for a specific movie.
4. Loan Record: Represents a record of a movie rental transaction.
5. Late Fee: Represents the late fees associated with members.
Q2. b) Draw state diagrams for each of the object types you identified above. (2.5 pts)
Hints:
Page 7 of 10
Test Design using state transition diagrams Lab exercise
You need one diagram for each type of object. Some diagrams may be very simple, but draw
them anyway for this exercise.
Do not draw the diagram the flow of use cases or scenarios. Individual steps in different use
cases may change the state of one object. State transition diagrams cut across use case scenarios.
Label each diagram by naming the type of object. For example, one diagram will show the states
of a copy of a movie.
Page 8 of 10
Test Design using state transition diagrams Lab exercise
1. Member State Transition Diagram:
States: New Member, Good Standing Member, Member with Fines
Transitions: Joining (New Member to Good Standing Member), Accruing Fines (Good Standing
Member to Member with Fines), Paying Fines (Member with Fines to Good Standing Member)
2. Movie Copy State Transition Diagram:
States: Available, Reserved, Rented
Transitions: Reservation (Available to Reserved), Renting (Available to Rented), Returning
(Rented to Available), Member Cancels Reservation (Reserved to Available)
3. Reservation State Transition Diagram:
States: Active, Canceled
Transitions: Reservation Made (Active), Member Cancels Reservation (Active to Canceled)
4. Loan Record State Transition Diagram:
States: Active, Closed
Transitions: Rental (Active), Return (Active to Closed)
5. Late Fee State Transition Diagram:
States: No Late Fee, Late Fee Incurred
Transitions: Movie Returned Late (No Late Fee to Late Fee Incurred), Late Fee Paid (Late Fee
Incurred to No Late Fee)
Q2.c) Identify criteria and define a test case to verify correct handling for four different state transitions.
For example, two test cases are listed here. Add four more (1 pts each). (4 pts)
1. Test case: member in good standing can rent a movie (no reservation required).
Criteria: A member with no fines can rent can rent any movie for which a copy is available,
without reservation.
Preconditions: Member 13 has no fines or reservations. Five copies of “Jaws” are available.
Action: Member 13 rents “Jaws”.
Expected result: One less copy of the movie is available than before. A loan record for the copy
of “Jaws” exists and is associated with member 13.
2. Test case: At the end of each day, the system clears reservations.
Criteria: Reservations for the day are cancelled by the system if the member does not collect the
movie by end of the business day.
Precondition: A copy of “Jaws” is on reserve for Member 108.
Action: The video store closes for the day
Expected result: After the system cleanup, the reservation record for Member 108 to collect
“Jaws” is deleted and the copy of “Jaws” is available.
3. Test Case: Member returns a movie late, and the system adds a late fee.
Page 9 of 10
Test Design using state transition diagrams Lab exercise
Criteria: A member returns a rented movie after the due time.
Preconditions: Member 22 has rented "The Matrix" and returns it late.
Action: Member 22 returns "The Matrix" late.
Expected Result: A late fee is added to Member 22's account, and the return status changes to
"Late."
4. Test Case: Member reserves a movie, but it's not available, and the system handles it.
Criteria: A member reserves a movie, but there are no available copies.
Preconditions: Member 33 reserves "Inception," and there are no available copies.
Action: Member 33's reservation is processed.
Expected Result: The reservation record for Member 33 remains, and the movie remains
"Unavailable."
5. Test Case: Member cancels a reservation.
Criteria: A member cancels an active movie reservation.
Preconditions: Member 77 has an active reservation for "Avatar."
Action: Member 77 cancels the reservation for "Avatar."
Expected Result: The reservation record for Member 77 is deleted, and "Avatar" becomes
available.
6. Test Case: A member in good standing rents a movie with a reservation.
Criteria: A member with no fines rents a reserved movie.
Preconditions: Member 44 has no fines, and there's a reserved copy of "The Avengers."
Action: Member 44 rents the reserved copy of "The Avengers."
Expected Result: Member 44's reservation is cleared, and a loan record is created for "The
Avengers."
End of exercise
Page 10 of 10