Cash dispenser VDM++ modellering Test af udvidet cash dispenser Peter Clausen Raghid Kawash Brian Gram Møller
Agenda ► Opfølgning fra sidst ► Valg af test miljø ► Test scenarier ► Gennemgang af udvalgte test cases ► Spørgsmål
Opfølgning fra sidst ► Før dcl num. Of. Trans: nat : = num. Of. Transactions, i: nat : = 0, tmp. Trans: seq of Transaction : = []; if len transactions < num. Of. Transactions then num. Of. Trans: = len transactions; i : = len transactions – num. Of. Trans + 1; while i <= num. Of. Trans do ( tmp. Trans : = tmp. Trans ^ [transactions(i)]; i : = i + 1; ); return tmp. Trans; ► Efter return [ transactions(t) | t in set inds transactions & t+num. Of. Transactions >= len transactions ];
Valg af test miljø ► VDMUnit framework
Test scenarier ► Deposit to account § Successful deposit into account ► Deposit to another account § Successful deposit into another account ► New withdrawal § Cash balanced at till ► Insert cash into till § Cash balanced at till ► Empty till cash amount § Withdrawal unavailable
Test scenarier ► Add 5 transactions and print last 10 § 5 transactions printed ► Empty printer, ink and paper § Printer not functional
Gennemgang af udvalgte test cases protected Test: () ==> () Test () == ( till. Insert. Card(card 1); Assert. True(till. Validate(card 1. Get. Code()) = ); Assert. True(till. insert. Bill(valid. Bill 500) = nil); Assert. True(till. insert. Bill(valid. Bill 1000) = nil); Assert. True(till. insert. Bill(invalid. Bill 200) = invalid. Bill 200); till. make. Deposit(); Assert. True(till. Get. Balance() = 6500); );
Gennemgang af udvalgte test cases protected Test: () ==> () Test () == (. . . clock. Set. Date("11. maj 2006"); . . . Assert. True(till. Cash. Amount = 2000); till. Insert. Card(card 2); Assert. True(till. Validate(card 2. Get. Code()) = ); Assert. False(till. Make. Withdrawal(2000, true)); Assert. True(till. insert. Bill(valid. Bill 1000) = nil); till. make. Deposit(); Assert. True(till. Make. Withdrawal(2000, true)); Assert. True(till. Cash. Amount = 1000); till. Return. Card(); Assert. False(till. can. Withdraw()); );
Gennemgang af udvalgte test cases protected Test: () ==> () Test () == ( printer. add. Paper(2); printer. add. Ink(10); till. Insert. Card(card 1); Assert. True(till. Validate(card 1. Get. Code()) = Assert. True(till. insert. Bill(valid. Bill 1000) = till. make. Deposit(); Assert. True(till. Make. Withdrawal(100, true)); Assert. True(till. Get. Balance() = 7800); Assert. True(till. Cash. Amount = 12800); --Using 5 lines of ink and 1 paper Assert. True(till. print. Last. Statements()); Assert. False(printer. is. Operational()); ); ); nil);
Opsummering ► Forbedringer fra sidst ► Afgjorde valg af test miljø ► Vist test scenarier ► Gennemgået udvalgte test cases
Spørgsmål ►. . .