Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sample Problems for Testing

Similar presentations


Presentation on theme: "Sample Problems for Testing"— Presentation transcript:

1 Sample Problems for Testing
For “Program” Level Testing: Triangle Next Date Sales Commission For “System” Level Testing: SATM system Currency conversion Windshield Wiper Garage Door Controller These 7 problems will be used throughout the remainder of the course as examples for different testing techniques Program Level Three examples will be used throughout in Chapters 5 through 9 to illustrate the various unit testing methods The triangle problem, a venerable example in testing circles. NextDate, a logically complex function Sales Commission, an example that typifies MIS applications. Higher Level, system level, Chapters 11 through 17 uses four other examples: The SATM system, a simplified version of an automated teller machine (ATM) The currency converter, an event-driven application typical of graphical user interface (GUI) applications The windshield wiper control device from the Saturn automobile A garage door controller, illustrates some of the issues of “systems of systems.”

2 1. Triangle Problem Problem (Requirements) Statement:
Write me a program that will accept 3 numbers which represent the 3 sides of a triangle. evaluate the inputs and determine if It is a triangle an isosceles triangle an equilateral triangle a scalene triangle Output the answer Problem: relating a) inputs to b) outputs based on input validity & input relationship Look at this requirement statement and identify areas of potential problem if you were writing the program anything more if you were testing this? (would you ensure that the outputs are tested via “partitioned” set?) Your textbook has an “improved” version of the requirement.

3 1. Triangle Problem The triangle problem is the most widely used example in software testing literature. Simple version: The triangle program accepts three integers, a, b, and c, as input. These are taken to be sides of a triangle. The output of the program is the type of triangle determined by the three sides: Equilateral, Isosceles, Scalene, or Not A Triangle.

4 1. Triangle Problem Improved version: “Simple version” plus better definition of inputs: The integers a, b, and c must satisfy the following conditions: c1. 1 ≤ a ≤ 200 c4. a < b + c c2. 1 ≤ b ≤ 200 c5. b < a + c c3. 1 ≤ c ≤ 200 c6. c < a + b

5 1. Triangle Problem If an input value fails any of conditions c1, c2, or c3, the program notes this with an output message, for example, “Value of b is not in the range of permitted values.” If values of a, b, and c satisfy conditions c1, c2, and c3, one of four mutually exclusive outputs is given: If all three sides are equal, the program output is Equilateral. If exactly one pair of sides is equal, the program output is Isosceles. If no pair of sides is equal, the program output is Scalene. If any of conditions c4, c5, and c6 is not met, the program output is NotATriangle

6 1. Triangle Problem Discussion
Problems persist! What output is expected for the input set (2, 2, 5)? Isosceles because a = b? NotATriangle because c > a+b? Fix it (sometimes testers must also be specifiers!) The Really Final Version: “Improved version” plus better definition of outputs.

7 2. Next Date Problem Problem (Requirements) Statement:
Write me a program that will accept 3 numbers which represent the day, month, and year of a calendar date evaluate the inputs and determine The next day of the date represented by the input output the next day answer Problem: relating inputs to outputs based on input validity & input relationship & “complex” data relationships Look at this requirement statement and identify areas of potential problem if you were writing the program anything more if you were testing this?

8 2. Next Date Problem NextDate is a function of three variables: month, date, and year. It returns the date of the day after the input date. The month, date, and year variables have integer values subject to these conditions: c1. 1 ≤ month ≤12 c2. 1 ≤ day ≤ 31 c ≤ year ≤ 2012 If any of conditions c1, c2, or c3 fails, NextDate produces an output indicating the corresponding variable has an out-of-range value — for example, “Value of month not in the range 1..12”. Because numerous invalid day–month–year combinations exist, NextDate collapses these into one message: “Invalid Input Date.”

9 3. Monthly Sales Commission Problem
Problem (Requirements) Statement: Write me a program that will accept 3 numbers which represent the number of locks, number of stocks, and number of barrels of a riflesold at each town during the month Will accept a number, -1, for locks to represent the “end” of monthly sales so sales commission can be computed evaluate the inputs and determine the monthly sales commission as follows: each lock price is $45; each stock price is $30; and each barrel price is $25 sales person is paid 10% of total sales for the first $1000; 15% on the next $800; and 20% in excess of $1800 output the sales commission Some sales “limitations” exist Must sell one complete rifle Monthly sales (production limit) must be: # of locks <71 # of stocks < 81 # of barrels < 91 Problem: Input – store - compute -output Look at this requirement statement and identify areas of potential problem if you were writing the program anything more if you were testing this?

10 4. SATM System Problem Problem (Requirements) Statement:
Develop part (a component) of an automatic teller system that: Displays a “welcome screen” with a simple instruction to insert ATM card Validates the ATM card. If invalid keeps it (with a message); otherwise goes on Asks for and validates a personal id number ( only up to 3 times) If valid, three “activity” options are presented: Check the account balance Withdraw from the account Deposit into the account Once the option is selected, the customer is presented with and asked to choose between a checking or a savings account For each of these 3 optional activities the customer account file is also updated with Date of ATM access and Increment the number of times this account is accessed through ATM

11 4. SATM System Problem

12 4. SATM System Problem (cont.)
Requirements (cont.) If account balance is requested then a new balance is printed and the customer is given a choice for more activities. For both withdrawal and deposit options, the customer is asked to key in the amount For withdrawal, the minimum increment is $10. The customer account will be updated, and the customer will be asked to take the cash from the dispenser. In the event there is insufficient funds, the customer is asked to re-key an amount For deposits, if the ATM terminal deposit is working (envelop exists and slot moves), then the customer is asked to place the deposit in an envelop and deposit through the ATM. Otherwise, the customer is told of the problem and given a choice of other options. When customer activities are complete, a new balance is printed on the receipt and a choice for more activities is given. If the customer chooses more activity, he is returned to the 3 choices of activities again. If the customer has no more activity then a message for customer to take both the receipt and the ATM card and the system ends. This testing would be closer to a component or system test, after each unit test is completed. How would divide the component into units for unit testing?

13 5. Currency Conversion Subsystem
Problem (Requirements) Statement: Develop a GUI based sub-system that will accept US currency and convert it to: Brazilian currency Canadian currency European community currency Japanese currency use the exchange rate within the last 12 hours. Also allow the “reverse currency” computation Note: more currencies than the textbook Look at this requirement statement and identify areas of potential problem if you were writing the program anything more if you were testing this?

14 5. Currency Conversion Subsystem

15 6. Saturn Windshield Wiper Controller
Problem (Requirements) Statement: Write me an “embedded” program that Controls the 4 speed settings of a windshield wiper: Off Intermittent Low High For “off”, the windshield wiper does not move For Intermittent setting, there are 3 “dial” sub-settings: 1 : wiper wipes 4 times per minute 2: wiper wipes 6 times per minute 3: wiper wipes 12 times per minute For Low, the wiper wipes 30 times per minute For High, the wiper wipes 60 times per minutes OFF -> Wiper does not move As a tester what needs to be considered? - if wiper is not moving, then ? Look at this requirement statement and identify areas of potential problem if you were writing the program anything more if you were testing this?

16 6. Saturn Windshield Wiper Controller
c1. Lever OFF INT LOW HIGH c2. Dial n/a 1 2 3 a1. Wiper speed is… 4 6 12 30 60

17 7. The Garage Door Controller (shown here as a SysML Context Diagram)


Download ppt "Sample Problems for Testing"

Similar presentations


Ads by Google