Sunday, April 19, 2009

What is State-Based Testing?

State-Based Testing

A program moves from state to state. In a given state, some inputs are valid, and others are ignored or rejected.

In response to a valid input, the program under test does something that it can do and does not attempt something that it cannot do. In state-based testing, we walk the program through a large set of state transitions and check the results carefully, every time. (Lessons Learned in Software Testing)

There are some systems that are essentially stateless in that for the same inputs they always give the same outputs or exhibit the same behavior. Many batch processing systems, computational systems, and servers fall in this category. There are, however, many systems whose behavior is state-based in that for identical inputs they behave differently at different times and may produce different outputs. The reason for different behavior is that the state of the system may be different. In other words, the behavior and outputs of the system depend not only on the inputs provided, but also on the state of the system. The state of the system depends on the past inputs the system has received. In other words, In software, many large systems fall in this category as past state is captured in databases or files and used to control the behavior of the system. For such systems, another approach for selecting test cases is the state-based testing approach.

If the set of states of a system is manageable, a state model of the system can be built. A state model for a system has four components:

– States. Represent the impact of the past inputs to the system.
– Transitions. Represent how the state of the system changes from one state to another in response to some events.
– Events. Inputs to the system.
– Actions. The outputs for the events.

The state model shows what state transitions occur and what actions are performed in a system in response to events. When a state model is built from the requirements of a system, we can only include the states, transitions, and actions that are stated in the requirements or can be inferred from them. Once the state model is built, we can use it to select test cases. When the design is implemented, these test cases can be used for testing the code. It is because of this we treat state-based testing as a black box testing strategy. [Source]

Few State Based Testing Resources:

State Based Testing with examples
SBT

State Based Testing with excellent examples
SBT

State Based Testing Elaborated
SBT

State Based Testing with an Example
SBT

A State-Based Testing Approach Providing Data Flow Coverage in Object-Oriented Class Testing
SBT