Testcover.com Testcover.com
Tutorial - Shopping Cart Example -
State Machine Test Models

Existing User Login
Sign up for Risk-Free Trial
About Testcover.com
Frequently Asked Questions
Tutorial with Examples
->Equivalence Partitioning
--->Shopping Cart Example
----->Seq. Unit Replay Design
->UML State Machines
--->Shopping Cart Example
--->Test Models, 1 Region
--->Design Procedure
--->Transition Designs
----->Functionally Dependent
----->Fixed Values
--->Target State Designs
----->Functionally Dependent
----->Fixed Values
--->Thermostat Example
->Definitions of Terms
WSDL Interface
Contact Information
In the shopping cart example two pairwise test models can be applied to the UML state machine:
• Transition model -- Each state transition in the region has one partition.
• Target state model -- The transitions to each target state in the region are combined into one partition.

The transition model has one partition for each transition between lowest-level leaf states in the region under test. Test factors include the current from state and the trigger event for the transition to the target to state. (The action of the resulting state change is an expected result, so the to state is not a test factor.) If program variables are needed to specify the extended state of the region, they are additional test factors.

The shopping cart has four leaf states (emptyCart, nonemptyCart, shopping and checkout) and eight transitions among them. Thus, there are eight partitions in the transition design.

State TransitionEvent(s)
1.shopping to emptyCart CART
2.nonemptyCart to emptyCart UPDATE
3.shopping to nonemptyCart CART
4.nonemptyCart to nonemptyCart CHECK(i)[0<=i&&i<n] QTY(i,q)[0<=i&&i<n] UPDATE
5.checkout to nonemptyCart CART
6.emptyCart to shopping SHOP
7.nonemptyCart to shopping SHOP
8.nonemptyCart to checkout CHECKOUT

The target state model reduces the number of partitions to yield fewer test cases. The test factors are the same as those for the transition model, including the current leaf state, trigger event and relevant program variables. The difference is that the target state model defines a partition to include all the transitions leading to a particular target state.

All four of the shopping cart leaf states can be target states. The eight transitions are grouped according to their target states into four partitions as follows.

State TransitionEvent(s)
1.shopping to emptyCart CART
1.nonemptyCart to emptyCart UPDATE
2.shopping to nonemptyCart CART
2.nonemptyCart to nonemptyCart CHECK(i)[0<=i&&i<n] QTY(i,q)[0<=i&&i<n] UPDATE
2.checkout to nonemptyCart CART
3.emptyCart to shopping SHOP
3.nonemptyCart to shopping SHOP
4.nonemptyCart to checkout CHECKOUT

The numbers of test cases resulting from the different designs are tabulated below.

Shopping Cart State Machine Test Designs
Transition Model Target State Model
Functionally dependent form 187 test cases in
8 partitions
172 test cases in
4 partitions
Fixed values form 234 test cases in
8 partitions
217 test cases in
4 partitions

Some of the transitions to the nonemptyCart state make use of functionally dependent factor values, so the numbers of test cases are shown for both the functionally dependent forms and the fixed values forms of the designs. The pages containing these designs describe the differences between the forms in more detail. A test model mapping relates the four designs on a block-by-block basis.

<Shopping Cart Example (revisited) Transition - Functionally Dependent>

Copyright © 2003-2021 Testcover.com, LLC. All rights reserved.