| Creating Custom Procedures |
|
The built-in Execution and Verification Procedures have the ability to execute several common tasks. However, there may be times when a specific procedure is required. The TestManager application may be extended by creating custom procedures. These procedures are created by writing a Java class that implements a specific interface, then registering the new procedure with the TestManager application. Once registered, the procedure may be used within Testcases in the same way as for built-in procedures. Execution Procedures
This interface class can be found in the TestManager.jar file in the root of the installation. Test Manager will invoke the methods of this class in the following order
This method is called first. A Context object is passed in. This object gives the procedure some information about its environment. The class definition is described below. It is a good idea to store a reference to this object in the implementation class.
This method is called to perform the execution. The method should return when the execution has completed, or failed, or been cancelled. If the method throws an exception then the application will mark the Testcase as failed.
If the user cancels the operation, the Cancel() method will be invoked. This should cause the Execute() method to terminate. A boolean value should be returned to indicate whether the execution was successfully cancelled. It is possible to provide an empty implementation of this method, in which case the Execution Procedure will not support the cancel operation. (The effect of this is that when the user cancels a run, the execution of this procedure will continue until completion, and then the run will halt.)
This method should return the progress of the execution, as a value between 0 and 100. Again, this method may be implemented in a simple manner by setting the progress as 0, until execution has completed, when the progress can be returned as 100.
This method should return the status of the execution, as an object of the following type:
The Set() method is used to set the status of the execution to one of the constant values defined in this class. The Context object is defined below:
The class provides context information for the Execution Procedure, as follows:
This method will return the value of the property with the given name, or null if the property could not be found.
This method will return the directory where the execution is taking place (ie: the staging area directory of the Testcase).
This method will return a PrintWriter object that can be used for writing messages to the execution log file.
This interface is found in the TestManager.jar file in the root of the installation. The system will invoke the methods of this class in the following order
This method is called first. A VerificationContext object is passed in (a sublass of the Context class used in the Execution Procedure). This object gives the procedure some information about its environment. The class definition is described below. It is a good idea to store a reference to this object in the implementation class.
This method is called to perform the verification. The method should return when the verification has completed, or failed. If the method throws an exception then Test Manager will mark the Testcase as failed.
This method should return the status of the verification, as an object of the following type:
The Set() method is used to set the status of the verification to one of the constant values defined in this class. The VerificationContext object is defined below:
The class provides context information for the Verification Procedure, as follows:
This method will return the directory where the benchmark results for this Testcase are stored (if the Testcase does not have any benchmark results, then this directory will not exist)
These methods return the start and end time of the Testcase execution, as the number of milliseconds since midnight, January 1, 1970. Sample Verification Procedure
Firstly, the application must be able to find the class file for the custom procedure. This can be placed in the classes directory in the root of the installation. Alternatively, the classpath used by the system may be extended to include extra directories or jar files. Secondly, the new procedure should be registered with the application using the menu options, as shown below:
Pressing the Register button will cause the following dialog to be displayed: The new procedure should be given a unique name, and the implementation class should be supplied. The checkbox indicates whether this is an Execution Procedure or a Verification Procedure. Finally, a set of properties can be added
to the procedure when it is registered. This is not really necessary,
but it can be helpful to add any properties that the custom
procedure requires. When the procedure is instantiated in a Testcase,
the list of properties will be shown to remind the user that these properties
need to be set.
|