1 / 23

Model-based Testing with UML

OBST. UMLT. Model-based Testing with UML. Vending Machine Usecase Diagram Vending Machine UseCase Spec Actor/UseCase Pairing Coverage criteria for Usecases UseCase-based test cases Vending Machine Class Diagram Vending Machine State Diagram Coverage Criteria for State Diagrams

cspitzer
Download Presentation

Model-based Testing with UML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OBST UMLT Model-based Testing with UML Vending Machine Usecase Diagram Vending Machine UseCase Spec Actor/UseCase Pairing Coverage criteria for Usecases UseCase-based test cases Vending Machine Class Diagram Vending Machine State Diagram Coverage Criteria for State Diagrams State-based test cases Vending Machine Activity Diagram Coverage criteria for Activity Diagrams Activity-based test cases Vending Machine sequence diagram Vending Machine collaboration diagram Coverage criteria for interaction diagrams Sequence-based test cases Collaboration-based test cases Object-oriented Test Architecture Concept of an OO test case Attributes of an OO test case System test case attributes by Sneed Test cases as classes 1 12 2 13 3 14 4 15 5 16 6 17 7 18 8 19 9 20 10 21 11 22

  2. UMLT-01 OBST Use Case Diagram of a Vending Machine Define Cooling Purchase Item Define Item Prices Maintain Dispenser Operator User Maintain Cash Unit

  3. UMLT-02 OBST Use Case Specification of a Vending Machine Use Case 1 Goal in context Actors Trigger Preconditions Postconditions (success) Postconditions (failure) Description main path Description alternative path Exceptions NF-Requirements Extensions Concurrent users Revisions Purchase Item Main scenario for purchasing an item from the vending machine. User. User inserts coins into slot or selects item on button panel. Vending machine is operational. Item is provided. Item is not provided. User inserts sufficient amount of money. User selects item on the panel. Selected item and return money are dispensed. User takes item and returned money, if applicable. User selects item Vending machine displays price. <basic course> [insufficient amount] user inserts more cash, or aborts. [selected item not available] user selects different item, or aborts. Item should be dispensed not more than 3 seconds after selection. After 3 seconds of no user selection use case is aborted and inserted cash is returned. <left open> <left open> <left open>

  4. UMLT-03 OBST Actor / Use Case Pairing Actor Usage Profile User Operator Operator Operator Operator Use Case Tester Component Purchase Item Define Cooling Define Item Price Maintain Dispenser Maintain Cash Unit

  5. UMLT-04 OBST Coverage Criteria for Use Cases Every use case should be tested at least once Every actor should be tested for all of his use cases Every trigger of every use case should be tested Every path thru a use case should be tested Every alternate path of a use case should be tested Every exception condition of a use case should be tested Every pre condition of a use case should be set Every post condition of a use case should be validated

  6. UMLT-05 OBST Use-Case-based Test Cases No. 1.1 1.2 2.1 2.2 2.3 3.1 3.2 4.1 precondition operational money = item.price Operational money < item.price money = item.price operational money > item.price operational Event user inserts coin money user selects item on panel user inserts coin money user selects item on panel user selects item on panel user inserts coin money user selects item on panel user selects item on panel Postcondition operational AND item provided item nor provided operational AND item provided operational AND item, change provided operational AND item not provided Result User takes item User takes item User takes item and change Price displayed

  7. UMLT-06 OBST Class Diagram for a Vending Machine <<Component>> Display <<Component>> DispenserUnit Price Dispense Item <<Subject>> VendingMachine << user operations>> insertCoins (CoinType Coin) selectedItem (SelectionType Item) <<variant>> insertCard (CardType Card) <<operator operations>> DefineCooling (Temperature Temp) defineItemPrices (SelectionType Item, Currency Price) maintainCashUnit() maintainDispenser() Selection Type Read Card Dispense Type Card Type Coin Type <<Component>> Display <<Component>> CardReader <<Component>> CashUnit

  8. UMLT-07 OBST State Diagram for a Vending Machine Selected Item [! EmptyItem ] Display Item Price Delay for 1 sec [else] Display Empty Delay for 1 sec 1 Idle Selected Item on Keypad [Amount = Item.Price] Dispense Item 2 10 Entry / Amount = 0 Display amount Selected Abort on Keypad / Return Inserted Coins Selected Item on Keypad [Amount > Item.Price] Dispense Item Dispense Change T1. Timeout / Dispense Inserted Coins 9 4 3 5 InsertCoin Selected Item on Keypad [Empty Item] Display Empty Dispense Change Entry / Amount += Coin.value T1.setTimer (3 sec) Display amount 8 6 InsertCoin T max < 3 sec Select Item on Keypad [ Amount < Item.Price ] 7

  9. UMLT-08 OBST Coverage Criteria for State Diagrams Each object should be tested Every instance state of each object should be tested Each state transition of each object should be tested Each combination of attribute values should be tested Every sequence of methods should be tested

  10. UMLT-09 OBST State-based Test Cases Initial State Idle Idle Idle Coins inserted Coins inserted Coins inserted Coins inserted Coins inserted Coins inserted Coins inserted No. 1 2 3 4 5 6 7 8 9 10 Precondition [EmptyItem] [!EmptyItem] [Amount < Item.Price] [Item.Empty] [Amount > Item.Price] [Amount = Item.Price] Transaction SelectItem (Item) SelectItem (Item) InsertCoin (Coin) SelectItem(Abort) Timeout() InsertCoin (Coin) SelectItem (Item) SelectItem (Item) SelectItem (Item) SelectItem (Item) Postcondition Display (Empty) Display (Item.Price) Display (Amount) Return Coins inserted Dispense inserted Coins Display (Amount) Display (Amount) Display Empty; Dispense Change Dispense Item; Dispense Change Dispense Item Final State Idle Idle Coins Inserted Idle Idle Coins Inserted Coins Inserted Idle Idle Idle

  11. UMLT-10 OBST Activity Diagram for a Vending Machine :Display :Vending Machine :Dispenser :Cash Unit Item [Item.Volume == 0] [Abort] 4 5 [else] Show Empty Dispense Amount [Amount < Item.Price] 1 6 [else] Give me More Money 2 Dispense Item Item.Volume = Item.volume - 1 Change = Amount - Item.Price [Change>0] 3 7 Dispense Change

  12. UMLT-11 OBST Coverage Criteria for Activity Diagrams Each action should be tested at least once (C0) Every Branch should be traversed at least once (C1) Every Path through the diagram should be traversed at least once (C2) All OR clauses of all conditions should be fulfilled (C3)

  13. UMLT-12 OBST Activity-based Test Cases Covered Path 1-2-3 1-2-7 4 5 1-6 Conditions for test case [Item.Volume > 0] [!Abort] [Amount == Item.Price] [Item.Volume > 0] [!Abort] [Amount > Item.Price] [Item.Volume == 0] [Abort] [Item.Volume > 0] [!Abort] [Amount < Item.Price] No. 1 2 3 4 5

  14. UMLT-13 OBST Sequence Diagram for a Vending Machine Sd selectItem <<Subject>> Vending Machine <<Component>> Display <<Component>> DispenserUnit <<Component>> CashUnit selectItem ( Item ) alt display ( Empty ) [ Item.Volume == 0 ] dispense ( Amount ) [ Abort ] display ( Amount ) [ Amount < Item.Price ] [ else ] alt [ Amount >= Item.Price ] dispense ( Item ) Item.Volume - 1 Change = Amount - Item.Price dispense ( Change ) [ Change > 0]

  15. UMLT-14 OBST Collaboration Diagram for a Vending Machine Sd selectItem <<Component>> :CashUnit 2: [ Item.ID == Abort ] dispense ( Amount ) 5.1: [ Item.Price < Amount ] dispense ( Change ) 1: selectItem ( Item ) <<Subject>> :VendingMachine <<Component>> :DispenserUnit 5: [!2-4] dispense ( Item ) User 3: [ Item.Volume == 0 ] display ( Empty ) 4: [ Item.Price > Amount ] display ( Amount ) <<Component>> :Display

  16. UMLT-15 OBST Coverage Criteria for Interaction Diagrams Each interaction should be tested Every class of correct messages should be sent For every interaction an incorrect message should be sent Correct messages should be sent to wrong objects Correct messages should be sent to deleted objects Every exception condition should be raised at least once All interactions should be tested for time outs

  17. UMLT-16 OBST Sequence bases Test-Cases Test Sequence [Item.Volume == 0] [Item.Volume > 0] [Abort] [Amount > Item.Price] [!Abort] [Amount < Item.Price] [Item.Volume > 0] [!Abort] [Amount >= Item.Price ] [Item.Volume > 0] [!Abort] [Amount >= Item.Price] [Amount > Item.Price] Conditions for test case Display.Show (Empty) CashUnit.Dispense (Amount) Display.Show (Item.Price) Dispenser.Dispense (Item) Dispenser.Dispense (Item) CashUnit.Dispense(Change) No. 1 2 3 4 5

  18. UMLT-17 OBST Collaboration-based Test Cases Test Sequence CashUnit.Dispense (Amount) Display.Show (Empty) Display.Show (Amount) Dispenser.Dispense (Item) CashUnit.Dispense (Change) Conditions for Collaboration [ Abort ] [ Item.Volume == 0 ] [ Item.Price > Amount ] [ !Abort ] [ Item.Volume > 0 ] [ Item.Price <= Amount ] [ Item.Price < Amount ] No. 1 2 3 4 5

  19. UMLT-18 OBST Object-oriented Test Architecture <<Subject>> Test Architecture 1..* 1..* Test Context Test Configuration Test Component 1..* Test Case SUT Arbiter

  20. UMLT-19 OBST Concept of a Test Case Super Test Case Test Objective <<Subject>> Test Case Test Behavior 1..* <<enumeration>> Verdict Test Trace pass fail error Inconclusive

  21. UMLT-20 OBST Attributes of an object-oriented Test Case An object-oriented Test Case should refer to a base or super test case from which it is derived should refer to one or more objects should refer to one or more requirements should refer to one or more use cases should have a unique identifier should have a purpose or goal should have one or more pre conditions should have one or more post conditions should have a source of derivation, i.e. a document should have a pass/fail criteria should have a responsible tester should have a status, e.g. defined, specified, tested, validated

  22. UMLT-21 OBST System Test Case Attributes Testfall- attribute Eindeutiges Identifikationsmerkmal Testfall ID Typ des Testfalls, z.B. Manuell oder automatisch Testfall Typ Zweck bzw. Ziel des Testfalls Testfall Zweck Woher der Testfall abgeleitet wurde Testfall Quelle Anforderung, die mit diesem Testfall getestet wird Anforderung Anwendungsfall, der mit diesem Testfall getestet wird Anwendungsfall Objekte, die von diesem Testfall betroffen sind Testobjekte* Testfall, der vorausgehen muss Vorgängerfall Ereignis, dass diesen Testfall auslöst Auslöser Vorzustände der betroffenen Objekte Vorbedingungen* Nachzustände der betroffenen Objekte Nachbedingungen* Eingangsdaten mit Wertebereichen Eingaben* Ausgangsdaten mit Wertebereichen Ausgaben* Umgebung, in der getestet wird Testumgebung Status des Testfalls Testfallstatus Verweis auf Fehlermeldungen * = mehrere Fehlermeldung

  23. UMLT-22 OBST Test Cases as Classes Generischer Testfall Attribute: Testumgebung Eingabedaten Ausgabedaten Methoden: Testfall_ermitteln Testfall_spezifizieren Testfall_testen Testfall_validieren Attribute: Name Typ Wertebereich Attribute: Name Typ Wertebereich Spezifischer Testfall Attribute: Testfall_ID Testfall_Typ Testfall_Zweck Testfall_Quelle Auslöser Vorbedingungen Nachbedingungen Testfall_Status Testfall_Datum Anforderung 1:1 m:1 Testszenario Anwendungsfall 1:1 Testobjekte 1:n 1:n Fehlermeldungen

More Related