Introduction to behaviors
Behaviors are reusable behavioral units that can expose utility or business logic for use within IBM® Rational® Test Virtualization Server.
They can be combined to build rich virtual servers (stubs) with minimal development effort.
A behavior interacts with a stub in two ways:
- It provides methods that can be used within script actions in the business logic of a stub. This enables the stub to control the behavior at run time.
- It can raise events to the stub, passing information that tells the stub that the behavior needs to interact in some way, such as sending a message.
Behaviors are discovered by
Rational® Test Virtualization
Server at
run time for use in stubs by means of an Eclipse extension: com.greenhat.tester.api.behaviour
and
they have the following four primary elements:
- The factoryClass is a Java™ class whose package is exported by the
behavior-contributing plug-in that implements the
com.greenhat.tester.api.behaviour.BehaviourFactory
interface. The implementation of the class creates and returns an implementation of the behavior and typically will configure and add listeners to it. - The behaviourInterface is a Java™ interface that is an extension of the
com.greenhat.tester.api.behaviour.LifecycleAwareBehaviour
interface whose package is exported by the behavior-contributing plug-in, which exposes the functions of the behavior. - The callbackInterface is a Java™ interface whose package is exported by the behavior-contributing plug-in and exposes the events exposed as call-backs by the behavior.
- The implementation of the behavior is custom code that is typically instantiated and configured by the factoryClass, which implements the behaviourInterface and makes call-backs on the callbackInterface.