...

Coverage Criteria for Use Cases

by user

on
Category:

hardware

60

views

Report

Comments

Transcript

Coverage Criteria for Use Cases
OBST
UMLT
Model-based Testing with UML
1
Vending Machine Usecase Diagram
12
Activity-based test cases
2
Vending Machine UseCase Spec
13
Vending Machine sequence diagram
3
Actor/UseCase Pairing
14
Vending Machine collaboration diagram
4
Coverage criteria for Usecases
15
Coverage criteria for interaction diagrams
5
UseCase-based test cases
16
Sequence-based test cases
6
Vending Machine Class Diagram
17
Collaboration-based test cases
7
Vending Machine State Diagram
18
Object-oriented Test Architecture
8
Coverage Criteria for State Diagrams
19
Concept of an OO test case
9
State-based test cases
20
Attributes of an OO test case
10
Vending Machine Activity Diagram
21
System test case attributes by Sneed
11
Coverage criteria for Activity Diagrams
22
Test cases as classes
UMLT-01
OBST
Use Case Diagram of a Vending Machine
Define
Cooling
Purchase
Item
User
Define
Item Prices
Operator
Maintain
Dispenser
Maintain
Cash Unit
UMLT-02
OBST
Use Case Specification of a Vending Machine
Use Case 1
Purchase Item
Goal in context
Actors
Trigger
Preconditions
Postconditions (success)
Postconditions (failure)
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.
Description main path
1.
2.
3.
4.
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.
Description alternative path
1.
2.
3.
User selects item
Vending machine displays price.
<basic course>
Exceptions
1.
2.
[insufficient amount] user inserts more cash, or aborts.
[selected item not available] user selects different item, or aborts.
NF-Requirements
1.
2.
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.
Extensions
Concurrent users
Revisions
<left open>
<left open>
<left open>
UMLT-03
OBST
Actor / Use Case Pairing
Actor
Use Case
Usage Profile
Tester Component
User
Purchase Item
Operator
Define Cooling
Operator
Define Item Price
Operator
Maintain Dispenser
Operator
Maintain Cash Unit
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
UMLT-05
OBST
Use-Case-based Test Cases
No.
precondition
Event
Postcondition
Result
1.1
operational
user inserts coin money
1.2
money = item.price
user selects item on panel
operational AND item provided
User takes item
2.1
Operational
user inserts coin money
2.2
money < item.price
user selects item on panel
item nor provided
2.3
money = item.price
user selects item on panel
operational AND item provided
User takes item
3.1
operational
user inserts coin money
3.2
money > item.price
user selects item on panel
operational AND item, change provided
User takes item and change
4.1
operational
user selects item on panel
operational AND item not provided
Price displayed
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
<<Component>>
Display
Read
Card
Card
Type
<<Component>>
CardReader
Coin
Type
Dispense
Type
<<Component>>
CashUnit
UMLT-07
OBST
State Diagram for a Vending Machine
Selected Item
1 [! EmptyItem ]
Selected Item on
Keypad [Amount =
Item.Price]
Dispense Item
Selected Item on
Keypad [Amount >
Item.Price]
Dispense Item
Dispense Change
Selected Item on
Keypad [Empty
Item]
Idle
10
9
Entry / Amount = 0
Display amount
Selected Abort on
Keypad
/ Return Inserted
Coins
4
3
Display Item Price
Delay for 1 sec
[else]
Display Empty 2
Delay for 1 sec
5
InsertCoin
8
Display Empty
Dispense Change
Entry /
Amount +=
Coin.value
T1.setTimer (3 sec)
Display amount
6
T1. Timeout
/ Dispense
Inserted
Coins
InsertCoin
T max < 3 sec
Select Item on Keypad
7 [ Amount < Item.Price ]
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
UMLT-09
OBST
State-based Test Cases
No.
Initial State
Precondition
Transaction
Postcondition
Final State
1
Idle
[EmptyItem]
SelectItem (Item)
Display (Empty)
Idle
2
Idle
[!EmptyItem]
SelectItem (Item)
Display (Item.Price)
Idle
3
Idle
InsertCoin (Coin)
Display (Amount)
Coins Inserted
4
Coins inserted
SelectItem(Abort)
Return Coins inserted
Idle
5
Coins inserted
Timeout()
Dispense inserted Coins
Idle
6
Coins inserted
InsertCoin (Coin)
Display (Amount)
Coins Inserted
7
Coins inserted
[Amount < Item.Price]
SelectItem (Item)
Display (Amount)
Coins Inserted
8
Coins inserted
[Item.Empty]
SelectItem (Item)
Display Empty; Dispense Change
Idle
9
Coins inserted
[Amount > Item.Price]
SelectItem (Item)
Dispense Item; Dispense Change
Idle
10
Coins inserted
[Amount = Item.Price]
SelectItem (Item)
Dispense Item
Idle
UMLT-10
OBST
Activity Diagram for a Vending Machine
:Display
:Vending Machine
Item
[Item.Volume
== 0]
:Dispenser
:Cash Unit
[Abort]
4
5
[else]
Show
Empty
[Amount <
Item.Price]
1
6
Give me
More Money
Dispense
Amount
[else]
2
Dispense
Item
Item.Volume =
Item.volume - 1
Change = Amount
- Item.Price
[Change>0]
3
7
Dispense
Change
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)
UMLT-12
OBST
Activity-based Test Cases
No.
Covered Path
Conditions for test case
1
1-2-3
[Item.Volume > 0]
[!Abort]
[Amount == Item.Price]
2
1-2-7
[Item.Volume > 0]
[!Abort]
[Amount > Item.Price]
3
4
[Item.Volume == 0]
4
5
[Abort]
5
1-6
[Item.Volume > 0]
[!Abort]
[Amount < Item.Price]
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
dispense ( Item )
[ Amount >= Item.Price ]
Item.Volume - 1
Change = Amount - Item.Price
dispense ( Change )
[ Change > 0]
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
5: [!2-4] dispense ( Item )
<<Component>>
:DispenserUnit
User
3: [ Item.Volume == 0 ] display ( Empty )
4: [ Item.Price > Amount ] display ( Amount )
<<Component>>
:Display
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
UMLT-16
OBST
Sequence bases Test-Cases
No.
Test Sequence
Conditions for test case
1
[Item.Volume == 0]
Display.Show (Empty)
2
[Item.Volume > 0]
[Abort]
CashUnit.Dispense (Amount)
3
[Amount > Item.Price]
[!Abort]
[Amount < Item.Price]
Display.Show (Item.Price)
4
[Item.Volume > 0]
[!Abort]
[Amount >= Item.Price ]
Dispenser.Dispense (Item)
5
[Item.Volume > 0]
[!Abort]
[Amount >= Item.Price]
[Amount > Item.Price]
Dispenser.Dispense (Item)
CashUnit.Dispense(Change)
UMLT-17
OBST
Collaboration-based Test Cases
No.
Test Sequence
Conditions for Collaboration
1
CashUnit.Dispense (Amount)
[ Abort ]
2
Display.Show (Empty)
[ Item.Volume == 0 ]
3
Display.Show (Amount)
[ Item.Price > Amount ]
4
Dispenser.Dispense (Item)
[ !Abort ]
[ Item.Volume > 0 ]
[ Item.Price <= Amount ]
5
CashUnit.Dispense (Change)
[ Item.Price < Amount ]
UMLT-18
OBST
Object-oriented Test Architecture
<<Subject>>
Test
Architecture
1..*
Test
Context
Test
Case
1..*
1..*
Test
Configuration
Test
Component
SUT
Arbiter
UMLT-19
OBST
Concept of a Test Case
Super
Test Case
Test Objective
<<enumeration>>
Verdict
pass
fail
error
Inconclusive
1..*
<<Subject>>
Test Case
Test Behavior
Test Trace
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
UMLT-21
OBST
System Test Case Attributes
Testfallattribute
Testfall ID
Eindeutiges Identifikationsmerkmal
Testfall Typ
Typ des Testfalls, z.B. Manuell oder automatisch
Testfall Zweck
Zweck bzw. Ziel des Testfalls
Testfall Quelle
Woher der Testfall abgeleitet wurde
Anforderung
Anwendungsfall
Anforderung, die mit diesem Testfall getestet wird
Anwendungsfall, der mit diesem Testfall getestet wird
Testobjekte*
Objekte, die von diesem Testfall betroffen sind
Vorgängerfall
Testfall, der vorausgehen muss
Auslöser
Ereignis, dass diesen Testfall auslöst
Vorbedingungen*
Vorzustände der betroffenen Objekte
Nachbedingungen*
Nachzustände der betroffenen Objekte
Eingaben*
Eingangsdaten mit Wertebereichen
Ausgaben*
Ausgangsdaten mit Wertebereichen
Testumgebung
Testfallstatus
Fehlermeldung
Umgebung, in der getestet wird
Status des Testfalls
Verweis auf Fehlermeldungen
* = mehrere
UMLT-22
OBST
Test Cases as Classes
Generischer Testfall
Eingabedaten
Attribute:
Name
Typ
Wertebereich
Attribute:
Testumgebung
Methoden:
Testfall_ermitteln
Testfall_spezifizieren
Testfall_testen
Testfall_validieren
Ausgabedaten
Attribute:
Name
Typ
Wertebereich
Spezifischer Testfall
Anforderung
Anwendungsfall
Testobjekte
1:1
1:1
1:n
Attribute:
Testfall_ID
Testfall_Typ
Testfall_Zweck
Testfall_Quelle
Auslöser
Vorbedingungen
Nachbedingungen
Testfall_Status
Testfall_Datum
m:1
1:n
Testszenario
Fehlermeldungen
Fly UP