Examples on Functional Testing Winter 2006 Presented by Nikos Giannopoulos nikos@swen.uwaterloo.ca ECE 453, Prof. Kontogiannis University of Waterloo 1 Agenda Telephone Billing Example Flowchart → Decision Table Example ECE 453, Prof. Kontogiannis University of Waterloo 2 Agenda Telephone Billing Example Flowchart → Decision Table Example ECE 453, Prof. Kontogiannis University of Waterloo 3 Telephone Billing Example The Spring and Fall changes between Standard and Daylight Savings time create an interesting problem for telephone bills. Develop equivalence classes for a long distance telephone service that bills calls at a flat rate of $0.05 per minute. Assume that the chargeable time of a call begins when the called party answers, and ends when the calling party disconnects ECE 453, Prof. Kontogiannis University of Waterloo 4 Telephone Billing Example For simplicity we consider a fixed Daylight Saving Time beginning date (March 13), and a fixed Standard Time beginning date (November 7) For simplicity we consider that time switches at midnight (March 13 and November 7) ECE 453, Prof. Kontogiannis University of Waterloo 5 Telephone Billing Example Inputs: Start Date Start Time End Date End Time Outputs: Charge Start Date & Time < End Date & Time ECE 453, Prof. Kontogiannis University of Waterloo 6 Telephone Billing Example Proposed equivalence relation: which are the crucial start/end dates to consider and which are the crucial start/end times that affect the billing procedure? ECE 453, Prof. Kontogiannis University of Waterloo 7 Telephone Billing Example Start Date Start Time ST1 = { startTime : startTime = 24h clock } End Date SD1 = { startDate : January 1 ≤ startDate < March 13 } SD2 = { startDate : startDate = March 13 } SD3 = { startDate : March 13 < startDate < November 7 } SD4 = { startDate : startDate = November 7 } SD5 = { startDate : November 7 < startDate ≤ December 31 } ED1 = { endDate : January 1 ≤ endDate < March 13 } ED2 = { endDate : endDate = March 13 } ED3 = { endDate : March 13 < endDate < November 7 } ED4 = { endDate : endDate = November 7 } ED5 = { endDate : November 7 < endDate ≤ December 31 } End Time ET1 = { endTime : endTime = 24h clock } ECE 453, Prof. Kontogiannis University of Waterloo 8 Telephone Billing Example Test Case WE1 WE2 WE3 WE4 WE5 Start Date Start Time End Date March 01, 2005 12:00 March 01, 2005 March 13, 2005 12:00 March 13, 2005 April 01, 2005 12:00 April 01, 2005 November 07, 2005 12:00 November 07, 2005 December 01, 2005 12:00 December 01, 2005 End Time 13:00 13:00 13:00 13:00 13:00 Expected Output ($) 3 3 3 3 3 Weak Equivalence Class Test Cases SD6 = { startDate : invalid dates } ED6 = { endDate : invalid dates } ST2 = { startTime : invalid times } ET2 = { endTime : invalid times } Test Case TE1 TE2 TE3 TE4 TE5 TE6 TE7 TE8 TE9 Start Date Start Time March 01, 2005 12:00 March 13, 2005 12:00 April 01, 2005 12:00 November 07, 2005 12:00 December 01, 2005 12:00 February 30, 2005 12:00 February 27, 2005 25:00 February 27, 2005 12:00 February 27, 2005 12:00 End Date March 01, 2005 March 13, 2005 April 01, 2005 November 07, 2005 December 01, 2005 March 01, 2005 March 01, 2005 February 30, 2005 March 01, 2005 End Time 13:00 13:00 13:00 13:00 13:00 13:00 13:00 13:00 25:00 Expected Output ($) 3 3 3 3 3 ERROR ERROR ERROR ERROR Traditional Equivalence Class Test Cases ECE 453, Prof. Kontogiannis University of Waterloo 9 Telephone Billing Example Test Case SE1 SE2 SE3 SE4 SE5 SE6 SE7 SE8 SE9 SE10 SE11 SE12 SE13 SE14 SE15 SE16 SE17 SE18 SE19 SE20 SE21 SE22 SE23 SE24 SE25 Start Time Start Date 12:00 March 12, 2005 22:00 March 12, 2005 22:00 March 12, 2005 22:00 March 12, 2005 22:00 March 12, 2005 22:00 March 13, 2005 22:00 March 13, 2005 23:00 March 13, 2005 22:00 March 13, 2005 22:00 March 13, 2005 22:00 March 14, 2005 22:00 March 14, 2005 22:00 March 14, 2005 22:00 November 06, 2005 22:00 March 14, 2005 22:00 November 07, 2005 22:00 November 07, 2005 22:00 November 07, 2005 22:00 November 07, 2005 22:00 November 07, 2005 22:00 December 01, 2005 22:00 December 01, 2005 22:00 December 01, 2005 22:00 December 01, 2005 22:00 December 01, 2005 End Date March 12, 2005 March 13, 2005 March 14, 2005 November 07, 2005 December 01, 2005 March 12, 2005 March 13, 2005 March 14, 2005 November 07, 2005 December 01, 2005 March 12, 2005 March 13, 2005 March 14, 2005 November 07, 2005 December 01, 2005 March 12, 2005 March 13, 2005 March 14, 2005 November 07, 2005 December 01, 2005 March 12, 2005 March 13, 2005 March 14, 2005 November 07, 2005 December 01, 2005 End Time 13:00 01:00 22:00 22:00 22:00 22:00 23:00 01:00 22:00 22:00 22:00 22:00 23:00 01:00 22:00 22:00 22:00 22:00 23:00 22:00 22:00 22:00 22:00 22:00 23:00 Expected Output ($) 3 6 141 do the math… do the math… ERROR 3 6 do the math… do the math… ERROR ERROR 3 12 do the math… ERROR ERROR ERROR 3 do the math… ERROR ERROR ERROR ERROR 3 Strong Equivalence Class Test Cases ECE 453, Prof. Kontogiannis University of Waterloo 10 Telephone Billing Example conditions c1: January 1 <= startDate < March 13 c2: startDate = March 13 c3: March 13 < startDate < November 7 c4: startDate = November 7 c5: November 7 < startDate <= December 31 c6: startTime (24h) c7: January 1 <= endDate < March 13 c8: endDate = March 13 c9: March 13 < endDate < November 7 c10: endDate = November 7 c11: November 7 < endDate <= December 31 c12: endTime (24h) actions a1: calculate charge accordingly a2: show error message conditions c1: January 1 <= startDate < March 13 c2: startDate = March 13 c3: March 13 < startDate < November 7 c4: startDate = November 7 c5: November 7 < startDate <= December 31 c6: startTime (24h) c7: January 1 <= endDate < March 13 c8: endDate = March 13 c9: March 13 < endDate < November 7 c10: endDate = November 7 c11: November 7 < endDate <= December 31 c12: endTime (24h) actions a1: calculate charge accordingly a2: show error message ECE 453, Prof. Kontogiannis 1 T T T T 2 T T T T 3 T T T T 4 T T T T 5 T T T T X X X X X 6 T T T T 7 T T T T 8 T T T T 9 T T T T 10 T T T T X X X X X 16 T T T T 17 T T T T 18 T T T T X X X 19 T T T T 20 T T T T X X 21 T T T T 22 T T T T 23 T T T T 24 T T T T X X X X 25 T T T T 11 T T T T 12 T T T T X X 13 T T T T 14 T T T T 15 T T T T X X X Decision Table X University of Waterloo 11 Agenda Telephone Billing Example Flowchart → Decision Table Example ECE 453, Prof. Kontogiannis University of Waterloo 12 Flowchart → Decision Table Example ECE 453, Prof. Kontogiannis University of Waterloo 13 Flowchart → Decision Table Example CONDITION A CONDITION B CONDITION C CONDITION D ACTION 1 ACTION 2 ACTION 3 CONDITION A CONDITION B CONDITION C CONDITION D ACTION 1 ACTION 2 ACTION 3 RULE 4.1 NO YES YES NO NO YES NO ECE 453, Prof. Kontogiannis RULE 1 YES YES I YES YES NO NO RULE 2 YES NO I I YES NO NO RULE 3 YES YES I NO NO YES NO RULE 4 NO I YES I NO YES NO RULE 5 NO I NO YES NO YES NO RULE 6 NO I NO NO NO NO YES RULE 1.1 RULE 1.2 RULE 2.1 RULE 2.2 RULE 2.3 RULE 2.4 RULE 3.1 RULE 3.2 YES YES YES YES YES YES YES YES YES YES NO NO NO NO YES YES YES NO NO NO YES YES YES NO YES YES YES NO NO YES NO NO YES YES YES YES YES YES NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO NO NO NO RULE 4.2 RULE 4.3 RULE 4.4 RULE 5.1 RULE 5.2 NO NO NO NO NO YES NO NO NO YES YES YES YES NO NO YES YES NO YES YES NO NO NO NO NO YES YES YES YES YES NO NO NO NO NO University of Waterloo RULE 6 NO YES NO NO NO NO YES RULE 6 NO NO NO NO NO NO YES 14 Agenda Telephone Billing Example Flowchart → Decision Table Example ECE 453, Prof. Kontogiannis University of Waterloo 15 References Software Testing A Craftsman's Approach 2nd edition, Paul C. Jorgensen, CRC Press (Chapters 5, 6, and 7) Software Testing Techniques, Second Edition, Boris Beizer ECE 453, Prof. Kontogiannis University of Waterloo 16