Vous êtes sur la page 1sur 18

Initial Functional Test Cases for Example ATM System

The following initial test cases can be identified early in the design process as a vehicle for checking that the implementation is basically correct. No attempt has been made at this point to do thorough testing, including all possible errors and boundary cases. That needs to come later. These cases represent an initial check that the functionality specified by the use cases is present. Some writers would argue for developing test cases like these in place of use cases. Here, they are presented as a vehicle for "fleshing out" the use cases, not as a substitute for them. Use Case System Startup System Startup Function Being Initial System Tested State System is started when the switch is System is off turned "on" System is System accepts requesting cash initial cash amount amount Input Expected Output

Activate the "on" System requests switch initial cash amount Enter a legitimate System is on amount

System Startup

System Shutdown

System Shutdown

Session

Session

Session

System output Perform a should demonstrate Connection to the System has just legitimate inquiry that a connection has bank is established been turned on transaction been established to the Bank System is shut System is on and down when the Activate the "off" not servicing a System is off switch is turned switch customer "off" Verify from the bank Connection to the side that a Bank is terminated System has just connection to the when the system is been shut down ATM no longer shut down exists System reads a System is on and Card is accepted; Insert a readable customer's ATM not servicing a System asks for card card customer entry of PIN Card is ejected; System is on and System displays an System rejects an Insert an not servicing a error screen; unreadable card unreadable card customer System is ready to start a new session System accepts System is asking Enter a PIN System displays a

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on" customer's PIN System allows customer to perform a transaction for entry of PIN

Input

Expected Output

Activate the "on" System requests switch initial cash amount menu of transaction types Perform a transaction System asks whether customer wants another transaction System displays a menu of transaction types

System is displaying menu Session of transaction types System is asking System allows whether multiple Session customer wants transactions in one another session transaction System is asking Session ends when whether customer chooses Session customer wants not to do another another transaction transaction Individual types of Transaction transaction will be tested below

Answer yes

Answer no

System ejects card and is ready to start a new session

Enter an incorrect System handles an The Invalid PIN A readable card PIN and then Transaction invalid PIN Extension is has been entered attempt a properly performed transaction System asks Menu of Choose System displays a customer to choose transaction types Withdrawal Withdrawal menu of account an account to is being transaction types withdraw from displayed System asks Menu of account System displays a customer to choose Choose checking Withdrawal types is being menu of possible a dollar amount to account displayed withdrawal amounts withdraw Withdrawal System performs a System is Choose an System dispenses legitimate displaying the amount that the this amount of cash; withdrawal menu of system currently System prints a transaction properly withdrawal has and which is correct receipt amounts not greater than showing amount and the account correct updated balance balance;

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on"

Input

Expected Output

Activate the "on" System requests switch initial cash amount System records transaction correctly in the log (showing both message to the bank and approval back)

System has been started up with less than the maximum System verifies that withdrawal it has sufficient Withdrawal amount in cash cash on hand to on hand; fulfill the request System is requesting a withdrawal amount System verifies that customer's balance Withdrawal is sufficient to fulfill the request System is requesting a withdrawal ammount

Choose an amount greater than what the system currently has

System displays an appropriate message and asks customer to choose a different amount

Choose an amount that the system currently has but which is greater than the account balance

A withdrawal transaction can be System is cancelled by the Press "Cancel" Withdrawal displaying menu customer any time key of account types prior to choosing the dollar amount A withdrawal transaction can be cancelled by the Withdrawal customer any time prior to choosing the dollar amount Deposit System asks

System is displaying menu Press "Cancel" of dollar key amounts Menu of Choose Deposit

System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays a

Use Case System Startup

Deposit

Function Being Tested System is started when the switch is turned "on" customer to choose an account to deposit to System asks customer to enter a dollar amount to deposit

Initial System State System is off

Input

Expected Output

Activate the "on" System requests switch initial cash amount menu of account types

transaction types is being transaction displayed

Deposit

Deposit

Deposit

Deposit

System displays a Menu of account Choose checking request for the types is being account customer to type a displayed dollar amount System is System asks displaying a System requests that Enter a legitimate customer to insert request for the customer insert an dollar amount an envelope customer to type envelope a dollar amount System accepts envelope; System prints a correct receipt showing amount and System is correct updated System performs a requesting that Insert an balance; legitimate deposit customer insert envelope System records transaction properly an envelope transaction correctly in the log (showing message to the bank, approval back, and acceptance of the envelope) System displays an A deposit appropriate message transaction can be System is and offers customer cancelled by the Press "Cancel" displaying menu the option of customer any time key of account types choosing to do prior to inserting an another transaction envelope or not. A deposit System is Press "Cancel" System displays an transaction can be requesting key appropriate message cancelled by the customer to and offers customer customer any time enter a dollar the option of prior to inserting an amount choosing to do envelope another transaction

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on"

Input

Expected Output

Activate the "on" System requests switch initial cash amount

Deposit

Deposit

Transfer

Transfer

Transfer

Transfer

or not. System displays an A deposit System is appropriate message transaction can be requesting and offers customer cancelled by the Press "Cancel" customer to the option of customer any time key insert an choosing to do prior to inserting an envelope another transaction envelope or not. A deposit System displays an transaction is System is appropriate message cancelled requesting Wait for the and offers customer automatically if an customer to request to time the option of envelope is not insert an out choosing to do inserted within a envelope another transaction reasonable time or not. System asks Menu of System displays a customer to choose transaction types Choose Transfer menu of account an account to is being transaction types specifying transfer from displayed transfer from System asks Menu of account System displays a customer to choose types to transfer Choose checking menu of account an account to from is being account types specifying transfer to displayed transfer to System asks Menu of account System displays a customer to enter a types to transfer Choose savings request for the dollar amount to to is being account customer to type a transfer displayed dollar amount System prints a correct receipt showing amount and System is correct updated System performs a displaying a balance; Enter a legitimate legitimate transfer request for the System records dollar amount transaction properly customer to type transaction correctly a dollar amount in the log (showing both message to the bank and approval back)

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on" A transfer transaction can be cancelled by the customer any time prior to entering dollar amount A transfer transaction can be cancelled by the customer any time prior to entering dollar amount A transfer transaction can be cancelled by the customer any time prior to entering dollar amount System asks customer to choose an account to inquire about

Input

Expected Output

Activate the "on" System requests switch initial cash amount System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays an appropriate message and offers customer the option of choosing to do another transaction or not. System displays a menu of account types

Transfer

System is displaying menu Press "Cancel" of account types key specifying transfer from

Transfer

System is displaying menu Press "Cancel" of account types key specifying transfer to

Transfer

System is requesting customer to enter a dollar amount

Press "Cancel" key

Inquiry

Menu of transaction types Choose Inquiry is being transaction displayed

Inquiry

Inquiry

System prints a correct receipt showing correct balance; System performs a System is Choose checking System records legitimate inquiry displaying menu account transaction correctly transaction properly of account types in the log (showing both message to the bank and approval back) An inquiry System is Press "Cancel" System displays an transaction can be displaying menu key appropriate message cancelled by the of account types and offers customer customer any time the option of

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on" prior to choosing an account

Input

Expected Output

Activate the "on" System requests switch initial cash amount choosing to do another transaction or not.

Invalid PIN Extension

Invalid PIN Extension

Invalid PIN Extension

Invalid PIN Extension

Invalid PIN Extension

Invalid PIN Extension Invalid PIN Extension

Enter an incorrect PIN; Attempt an Customer is asked Customer is asked to inquiry to reenter PIN re-enter PIN transaction on the customer's checking account Request to reOriginal transaction Correct re-entry of enter PIN is Enter correct PIN completes PIN is accepted being displayed successfully An incorrect PIN A correctly rehas been reThis transaction entered PIN is used entered and Perform another completes for subsequent transaction transaction successfully as well transactions completed normally An appropriate Request to remessage is displayed Incorrect re-entry of Enter incorrect enter PIN is and re-entry of the PIN is not accepted PIN being displayed PIN is again requested Enter incorrect Correct re-entry of Request to reOriginal transaction PIN the first time, PIN on the second enter PIN is completes then correct PIN try is accepted being displayed successfully the second time Enter incorrect Correct re-entry of Request to re- PIN the first time Original transaction PIN on the third try enter PIN is and second times, completes is accepted being displayed then correct PIN successfully the third time Three incorrect re- Request to re- Enter incorrect An appropriate entries of PIN result enter PIN is PIN three times message is in retaining card being displayed displayed; and aborting Card is retained by transaction machine;

Use Case System Startup

Function Being Initial System Tested State System is started when the switch is System is off turned "on"

Input

Expected Output

Activate the "on" System requests switch initial cash amount Session is terminated

Analysis Classes
An initial reading of the use cases suggests that the following will be part of the system.

A controller object representing the ATM itself (managing the boundary objects listed below.) Boundary objects representing the individual component parts of the ATM:
o o o o o o o

Operator panel. Card reader. Customer console, consisting of a display and keyboard. Network connection to the bank. Cash dispenser. Envelope acceptor. Receipt printer.

Controller objects corresponding to use cases. (Note: class ATM can handle the Startup and Shutdown use cases itself, so these do not give rise to separate objects here.)
o o

Session Transaction (abstract generalization, responsible for common features, with concrete specializations responsible for type-specific portions)

An entity object representing the information encoded on the ATM card inserted by customer. An entity object representing the log of transactions maintained by the machine.

This leads to the following diagram of analysis classes:

Click on a class icon to go to links to various kinds of information about it

CRC Cards for ATM Example

Using CRC cards to assign responsibiities to various classes for the tasks required by the various use cases leads to the creation of the following cards. The following links can be used to go directly to the CRC cards for the various classes:

Class ATM Boundary/entity objects - component parts of the ATM


o o o o o o o o

Class CardReader Class CashDispenser Class CustomerConsole Class EnvelopeAcceptor Class Log Class NetworkToBank Class OperatorPanel Class ReceiptPrinter

Controller objects corresponding to the various use cases


o o o o o o

Class Session Class Transaction Class Withdrawal Class Deposit Class Transfer Class Inquiry

Entity objects found necessary when assigning responsiblities to other objects


o o o o o

Class Balances Class Card Class Message Class Receipt Class Status

Class ATM
Responsibilities Collaborators

Start up when switch is turned on Shut down when switch is turned off Start a new session when card is inserted by customer Provide access to component parts for sessions and transactions [ Links for this class ]

OperatorPanel CashDispenser NetworkToBank NetworkToBank CustomerConsole Session

Class CardReader
Responsibilities Tell ATM when card is inserted Read information from card Eject card Retain card [ Links for this class ] Collaborators ATM Card

Class CashDispenser
Responsibilities Keep track of cash on hand, starting with initial amount Report whether enough cash is available Dispense cash [ Links for this class ] Collaborators

Log

Class CustomerConsole
Responsibilities Display a message Display a prompt, accept a PIN from keyboard Display a prompt and menu, accept a choice from keyboard Display a prompt, accept a dollar amount from keyboard Respond to cancel key being pressed by customer [ Links for this class ] Collaborators

Class EnvelopeAcceptor
Responsibilities Accept envelope from customer; report if timed out or cancelled [ Links for this class ] Collaborators Log

Class Log
Responsibilities Log messages sent to bank Log responses from bank Log dispensing of cash Log receiving an envelope [ Links for this class ] Collaborators

Class NetworkToBank
Responsibilities Initiate connection to bank at startup Send message to bank and wait for response Collaborators Message Log Balances Status

Terminate connection to bank at shutdown [ Links for this class ]

Class OperatorPanel
Responsibilities Inform ATM of changes to state of switch Allow operator to specify amount of initial cash [ Links for this class ] Collaborators ATM

Class ReceiptPrinter
Responsibilities Print receipt [ Links for this class ] Collaborators Receipt

Class Session
Responsibilities Perform session use case Collaborators ATM CardReader Card CustomerConsole Transaction

Update PIN value if customer has to re-enter it

[ Links for this class ]

Abstract Class Transaction


Responsibilities Allow customer to choose a type of transaction Collaborators ATM CustomerConsole Withdrawal Deposit Transfer Inquiry ATM CustomerConsole Withdrawal Deposit Transfer Inquiry Message NetworkToBank Receipt ReceiptPrinter CustomerConsole Session CardReader

Perform Transaction Use Case

Perform invalid PIN extension

[ Links for this class ]

Class Withdrawal
Responsibilities Collaborators Perform operations peculiar to withdrawal transaction use case CustomerConsole CashDispenser Message Receipt

[ Links for this class ]

Class Deposit
Responsibilities Perform operations peculiar to deposit transaction use case Collaborators CustomerConsole Message EnvelopeAcceptor Receipt

[ Links for this class ]

Class Transfer
Responsibilities Perform operations peculiar to transfer transaction use case Collaborators CustomerConsole Message Receipt

[ Links for this class ]

Class Inquiry
Responsibilities Perform operations peculiar to inquiry transaction use case Collaborators CustomerConsole Message Receipt

[ Links for this class ]

Class Balances
Responsibilities Represent account balance information returned by bank Collaborators

[ Links for this class ]

Class Card
Responsibilities Represent information encoded on customer's ATM card Collaborators

[ Links for this class ]

Class Message
Responsibilities Represent information to be sent over network to bank Collaborators

[ Links for this class ]

Class Receipt
Responsibilities Represent information to be printed on a receipt Collaborators

[ Links for this class ]

Class Status

Responsibilities Represent transaction status information returned by bank

Collaborators

[ Links for this class ]

Class Diagram for Example ATM System


Shown below is the class diagram for the ATM system. The basic structure of the class diagram arises from the responsibilities and relationships discovered when doing the CRC cards and Interaction Diagrams. (If a class uses another class as a collaborator, or sends a message to an object of that class during an Interaction, then there must either be an association linking objects of those classes, or linking the "sending" class to an object which provides access to an object of the "receiving" class.) In the case of the ATM system, one of the responsibilities of the ATM is to provide access to its component parts for Session and Transaction objects; thus, Session and Transaction have associations to ATM, which in turn has associations to the classes representing the individual component parts. (Explicit "uses" links between Session and Transaction, on the one hand, and the component parts of the ATM, on the other hand, have been omitted from the diagram to avoid making it excessively cluttered.) The need for the various classes in the diagram was discovered at various points in the design process.

Some classes were discovered when doing analysis (see the Analysis Class Diagram developed earlier.) Some classes were discovered when doing CRC cards
o o o o

Message - used to represent a message to the bank. Receipt - used to encapsulate information to be printed on a receipt. Status - used to represent return value from message to the bank. Balances - used to record balance information returned by the bank.

Some classes were discovered when doing detailed design or writing code
o o

Money - used to represent money amounts, in numerous places. AccountInformation - contains names of various types of accounts customer can choose from

That is, OO design is not a "waterfall" process - discoveries made when doing detailed design and coding can impact overall system design.

To prevent the diagram from becoming overly large, only the name of each class is shown - the attribute and behavior "compartments" are shown in the detailed design, but are omitted here.

Click on a class icon for links to further information about it

State Charts for Example ATM System


Three of the objects we have identified have behavior that is sufficiently complex to warrant developing a State Chart for them. (These are the objects that were identified as the major controller objects.)

The object representing the machine itself (responsible for the System Startup and Shutdown use cases) Objects representing a customer session (one per session) (responsible for the Session use case) Objects representing an individual transaction (one per transaction) (responsible for the Transaction use case, use cases for the specific types of transaction, and Invalid PIN extension).