To help analyze your model, it is often beneficial to add an auxiliary Statechart that monitors or drives your model during analysis. These Statecharts are called Testbenches. Testbenches have the unique ability to relate to all the elements in the simulation scope.
Syntactically, Testbench charts are no different than other Statecharts. Semantically, however, all elements in the scope are visible to the Testbench. Testbench charts can be used in the following ways:
Statecharts that help monitor, debug or check the performance of parts of the system. These charts do not influence the behavior of the system. Statecharts which are currently not part of the system but may be integrated later as part of the entire specification.The following figure represents a simple Statechart where the event E is detected and causes a transition from state A1 to A2 during this transition the value of X is incremented. This Statechart is the specification of a system, where the event E is defined as coming from the environment and the system reacts to it.
Assume that the specification also states that if event E occurs, it must wait 5 time-units before reoccurring. This is expressed in the Testbench Statechart as shown in the following figure. Also assume that once X is equal to 10, event E is no longer generated.
When the Testbench chart is simulated with chart SPEC, the reference to E in the Testbench is resolved to event E defined in SPEC. Therefore, SPEC receives E every 5 time-units until X gets the value of 10.
Note: The elements X and E is defined to a chart in the model, but must be left unresolved in the testbench Statechart.