"SfR Fresh" - the SfR Freeware/Shareware Archive 
|
TestMaker is an easy to use utility for building intelligent test agents. This tutorial will show the steps needed to build a test agent, including:
After reading this tutorial we recommend you check out these:
A guide to the example agents that come with TestMaker
A list of frequently asked questions
TestMaker Script Language Reference
TestMaker
comes as a set of files that are compressed into a ZIP archive. To
install TestMaker, uncompress the archive into a TestMaker directory.
The TestMaker documentation will refer to testmaker_home as the
directory into which the TestMaker files are uncompressed.
The testmaker_home directory contains these files:
TestMaker comes with everything needed to build and run intelligent test agents. TestMaker expects to find a Java 1.4 or higher compliant virtual machine already installed.
From time-to-time we update TestMaker to solve bugs and introduce new features. The PushToTest Web site home page shows the most recent version number. Downloads are available there too. The latest update to TestMaker is always found at http://downloads.pushtotest.com/TestMaker.zip.
Answers to common installation problems are found here.
TestMaker 4 is a Swing-based Java application that offers many of the features a software developer, QA technician and IT manager would expect to find in an integrated development environment. TestMaker comes with a powerful screen editor, output panel, test agent execution controls, visual file system navigator, online help, and a New Agent Wizard.

This screen shot of the TestMaker graphical environment shows many of the elements used commonly to create and run test agents:
Building and running test agents in TestMaker is straight-forward and easy. In this section we will run a sample agent and then show how to create a new agent. The screen shots in this section were taken with a freshly installed TestMaker.
This tutorial uses the sample test agents in the testmaker_home/agents directory. The agents are fully functional and most connect to the examples.pushtotest.com site, hosted by PushToTest.
To begin, start TestMaker by running the TestMaker.bat or TestMaker.sh scripts found in testmaker_home/. The TestMaker graphical environment includes features to edit agent scripts, browse file systems for agent files, view output, and control execution of agents. With TestMaker up and running you may immediately begin using any of the included sample test agents.
When TestMaker starts for the first time the Quick Start Helper window appears. Click the Dismiss This Window button.
The Buffers list on the left displays the TestMaker_home directory and the editor panel displays a list of the directory contents, including the agents subdirectory. Use the mouse to double-click the example_agents directory. Double-click the HTTP_Example.py sample test agent script.
HTTP_Example is a shows how TestMaker will make a request to the examples.pushtotest.com Web application using HTTP protocols. We will cover the script commands needed to accomplish this agent in the Understanding Scripts section later in this tutorial. For now, please accept that the agent script works and that the TestMaker graphical environment offers features to view and execute agents.

The lower right Execution panel offers test agent controls to run, pause, and stop test agent scripts. The two left buttons are for running a test agent locally or running a test agent on a group of TestNetwork TestNodes.
Click the left-most Run button in the Execution panel in the lower-left portion of the TestMaker window. You may alternatively choose Run from the Agent drop-down menu. The agent name appears in the list below the control buttons.
TestMaker executes agents by creating a new thread for the
agent. The running agent appears in the running-agents list below the buttons.
Output from the agent appears in the output panel below the script editor window. The
output from the HTTPS_Connect agent should look something like this:
=======================================================
HTTPExample: Functional test of a Web application
=======================================================
Test created by TestMaker from http://www.pushtotest.com
HTTPExample: Initialize
test: setUp
test: runTest
Request step: 1, http://examples.pushtotest.com/responder/htmlresponder
Parsing images
Request step: 2, http://examples.pushtotest.com/responder/htmlresponder
Parsing images
Request step: 3, http://examples.pushtotest.com/responder/htmlresponder
Parsing images
Request step: 4, http://examples.pushtotest.com/responder/htmlresponder
Parsing images
Request step: 5, http://examples.pushtotest.com/responder/htmlresponder
Parsing images
test: tearDown
done
The HTTP_Example agent receives several HTML pages over an HTTP
connection. Each page is parsed for image tags and the images are
loaded from the Web site. If a page or image is unavailable then the
agent script displays an exception message.
Of course TestMaker also handles more complex calls to Web Services using SOAP and XML-RPC protocols. We will next open a second agent to see TestMaker's graphic environment handling more than one agent at once.
Next we will see how to create a new test agent using the helpful New Agent Wizard. Choose the File -> New command or click the New icon.

The New Wizard is capable of building test agent scripts that implement jUnit TestCases for testing HTML forms and SOAP-based Web Services. The new Agent Recorder watches you drive a Web application using your browser and writes a test agent script for you.
The Tools -> Preferences dialog box now includes a Recorder tab to set the port number of the proxy service for the Agent Recorder. By default, the proxy port is 8090. You need to tell your browser to use the proxy port for the record to function. The Agent Recorder does not support HTTPS connections at this time.
When you choose the Record From A Web Browser button the Wizard will begin recording your operation of a browser-based Web application. Click the Stop button to end the recording. The Wizard will display a File Selector and ask you to enter an agent file name. The new agent will appear in the Editor panel.
Additional information about the Agent Recorder is found here.
Using The Recorder
The Agent Recorder watches you drive a Web-enabled application using your browser and writes a test agent script for you. You may play-back the test agent script in TestMaker or from the command-line to perform a functional (unit) test. Recorded test agents may be plugged-into the XSTest framework to conduct scalability, performance and plugged-into the Service Monitor System (SMS) for a live dashboard that monitors the service.
The Recorder is built around a smart proxy server that watches for HTTP traffic between your browser and the service. The proxy decodes HTTP GET and POST commands from the browser and the responses from the server. The proxy then writes the Jython and TOOL script commands necessary to replay your use of the Web-enabled application. This design supports HTTP 1.0 and 1.1 compliant browsers, including the use of JavaScript, plug-ins, and ActiveX objects, and Java applets.
The Agent Recorder does not support HTTPS connections. By the time the TestMaker proxy receives the request from the browser, the request is encrypted and TestMaker is not able to decode the body of the HTTP protocol. The only workaround at this time is to temporarily host your application with SSL encryption turned-off while you record the test and then turn on SSL encryption when you play-back the test.
Before using the Recorder you will need to configure your browser to communicate through the Recorder proxy. By default, TestMaker sets the proxy port to 8090. Your browser preferences is usually the place to set the used proxy port to be used. Each browser is different at controlling the proxy server. For example, in Microsoft Internet Explorer 6.0 for Windows 2000, the proxy server settings are found by choosing the Internet Options command in the Tools drop-down menu. Choose the Connections tab and click the LAN Settings... button. The lower portion of the dialog that appears controls the Proxy server settings.

If port 8090 is already in use on your system then change the TestMaker proxy server to use a different port number. In TestMaker choose the Preferences command in the Help drop-down menu and then choose the Recorder tab.
With the proxy settings configured, every request from the browser will go through TestMaker's proxy server. This has a side effect in that TestMaker needs to be running for you to use your browser.
Next we will Record a test of the Web-enabled application hosted at examples.pushtotest.com. The application is a simple servlet that responds with Web pages. Depending on the parameters send to the servlet the response can be a Web page containing random content, responses to HTTP Post commands with HTML forms, and provides a Web site with HTML links our recorded test will follow.
Follow these steps:
1. Configure your browser to use Proxy port 8090.
2. Start TestMaker.
3. Choose File -> New -> HTML Agent Recorder or click the Recorder button.
4. TestMaker displays a dialog asking for the name of the new test agent. Type MyFirstTest.
5. Click the Start Recording button.
6. Point
your browser to this URL: http://examples.pushtotest.com/responder/htmlresponder

7. Click the file2.html link. You should find the link about halfway down the Web page.
8. The browser will display a new Web page that contains two forms. In the top-most form, enter your first and last name, and your phone number. Then enter 1081 as the account number and 75.36 in the amount field. Click the Transfer Funds button.
9. Your browser will show a new Web page that echoes the HTML form information you submitted on the previous page.
10. Return to TestMaker and click the Stop Recording button.
11. TestMaker will display a standard file selector dialog. Navigate to the directory you wish to store the new agent, enter a file name for the agent, and click the Save button.
12. The new test agent script will appear in the Editor panel in TestMaker.
Congratulations. You recorded your first test agent script.
To play-back the new agent script, click the Run icon in the Execution panel. Alternatively you may choose the Run command in the Agent drop-down menu.
The agent will replay the steps you took while using the browser to drive the Web-enabled application on the examples.pushtotest.com domain. You will see the results of the play-back in the Output panel.
Click here for further information on the Recorder.
TestMaker comes with a powerful object-oriented scripting language and the Test Object Oriented Library (TOOL.) The Jython scripting language offers variables and regular expressions, advanced script flow controls, and multiple-file test agent script capabilities. TOOL offers protocol handlers, datasource handlers and utility objects to handle all the communication with a service using HTTP, HTTPS, SOAP, XML-RPC, SMTP, POP3, and IMAP protocols. The script language and TOOL make TestMaker a powerful and extensible platform for developing intelligent test agents.
Jython is a 100% Java implementation of the popular Python scripting language. Python is supported by many how-to books and an active developer community. TestMaker comes with a library of sample test agents to learn the scripting language and TOOL syntax. The scripting language is integrated into TestMaker and internally implemented in Java. As a result test agents may use the Python script commands and objects and Java objects in any combination.
Next we look into these agents to learn how to construct TestMaker scripts.
HTTP_Example agent makes a set of requests over an HTTP connection. Here is the HTTP_Example.py agent script in its entirety and followed-by a detailed explanation of its components.
'''
Agent name: HTTP_Example.py
Created on: April 17, 2006
Created by: Frank Cohen (fcohen@pushtotest.com)
'''
from com.pushtotest.tool.protocolhandler import ProtocolHandler, HTTPProtocol
from com.pushtotest.tool.response import Response
import junit
from java.util import Date
import sys, re, time
from java.lang import Exception
from com.pushtotest.tool.util import URLCodec
import agentbase
reload(agentbase)
class HTTPExample( agentbase.agentbase, junit.framework.TestCase ):
'''
Base class implements abstract methods need by recorded test agent script.
'''
def __init__( self, debuglevel = 0, logto="console", follow_redirects=0, \
successcodes='20.|300|301|302|303|304|307|401|403|408|41.', \
logpath="log.txt", sleeptime_min=0, sleeptime_max=0, imagesleeptime=0, \
loadimgtags = "1", imagecache = "1", agentname="test", openlog=1 ):
''' Initialize this test '''
# Call the agentbase superclass's init method
agentbase.agentbase.__init__( self, debuglevel, logto, follow_redirects, \
successcodes, logpath, sleeptime_min, sleeptime_max, imagesleeptime, \
loadimgtags, imagecache, agentname, openlog )
junit.framework.TestCase.__init__(self, agentname)
def setUp( self ):
''' Add any needed set-up code here. '''
self.log( 1, "test: setUp" )
self.config()
def runTest( self ):
''' Run the test '''
self.log( 1, "test: runTest" )
self.get( '''http://examples.pushtotest.com/responder/htmlresponder''')
self.params = [ [ '''file''', '''file1.html''' ] ]
self.get( '''http://examples.pushtotest.com/responder/htmlresponder''', self.params)
self.params = [ [ '''file''', '''file2.html''' ] ]
self.get( '''http://examples.pushtotest.com/responder/htmlresponder''', self.params)
self.params = [ [ '''firstname''', '''Frank''' ],[ '''lastname''', '''Cohen''' ],[ '''phone''', '''408 374 7426''' ],\
[ '''account''', '''3828 3847 1783''' ],[ '''amount''', '''101.75''' ],[ '''Transfer''', '''Transfer Funds''' ] ]
self.post( '''http://examples.pushtotest.com/responder/htmlresponder''', self.params)
self.params = [ [ '''file''', '''file3.html''' ] ]
self.get( '''http://examples.pushtotest.com/responder/htmlresponder''', self.params)
def tearDown( self ):
''' Add any needed code to end the test here. '''
self.log( 1, "test: tearDown" )
if __name__ == 'main':
print '======================================================='
print 'HTTPExample: Functional test of a Web application '
print '======================================================='
print
test = HTTPExample( 1, 'console file ', 0, '20.|300|301|302|303|304|307|401|403|408|41.',\
'log.xml', 5, 10, 2, 1, 1, 'HTTPExample', 1 )
test.setUp()
test.runTest()
test.tearDown()
test.closelog()
print "done"
Lets look at the individual sections of the agent script to learn
what the script does to communicate with the Web
host.
from com.pushtotest.tool.protocolhandler import ProtocolHandler, HTTPProtocol
from com.pushtotest.tool.response import Response
import junit
from java.util import Date
import sys, re, time
from java.lang import Exception
from com.pushtotest.tool.util import URLCodec
import agentbase
reload(agentbase)
The script begins with several import statements. These tell TestMaker where to find the protocol handler objects (HTTPProtocol) and other utilities that will be used later in the script. Details on the TOOL objects are found in the TOOL Reference Guide. (Note that these imports are identifying Java objects, not just Jython objects.) The agentbase module provides test agent scripts with many useful functions, including protocol handler creation, log file handlers, and <img> tag reference validation. The agentbase module is found in testmaker_home/lib.
Next the script defines the HTTPExample class and initialization methods.
class HTTPExample( agentbase.agentbase, junit.framework.TestCase ):
'''
Base class implements abstract methods need by recorded test agent script.
'''
def __init__( self, debuglevel = 0, logto="console", follow_redirects=0, \
successcodes='20.|300|301|302|303|304|307|401|403|408|41.', \
logpath="log.txt", sleeptime_min=0, sleeptime_max=0, imagesleeptime=0, \
loadimgtags = "1", imagecache = "1", agentname="test", openlog=1 ):
''' Initialize this test '''
# Call the agentbase superclass's init method
agentbase.agentbase.__init__( self, debuglevel, logto, follow_redirects, \
successcodes, logpath, sleeptime_min, sleeptime_max, imagesleeptime, \
loadimgtags, imagecache, agentname, openlog )
junit.framework.TestCase.__init__(self, agentname)
def setUp( self ):
''' Add any needed set-up code here. '''
self.log( 1, "test: setUp" )
self.config()
The TestMaker scripting language - Jython - is a full featured language with support for object oriented development. In the above code a new class named HTTPExample will be used to run the test. The HTTPExample class inherits the agentbase functions and implements a JUnit TestCase.
The __init__() and setUp() methods define a set of default parameters, including the debug logging level, where to sent status and error messages, and several other parameters.
def runTest( self ): |
The TestCase requires three methods: setUp(), runTest(), and tearDown(). The runTest() method does the work of issuing commands to get the Web page at the examples.pushtotest.com site. The self.post() method issues an HTTP Post command to the site and the self.get() method issues an HTTP Get command to the site. A TestCase uses assertions to identify problems. When a self.get() or self.post() response from the Web site does not contain one of the success code values (for instance, 200, 300, etc.) then you will see an exception thrown.
if __name__ == 'main': |
Lastly, the agent
script includes a 'main' method to instantiate an HTTPExample object
and run its test when the agent script is run directly through the
Execution console's Run button.
All of this scripting and TOOL object stuff may look complicated. But fear not! TestMaker comes with a test agent script Recorder. In fact, the Recorder created the HTTP_Example.py test agent script automatically from the use of a Web browser and the examples application.
Additionally, the TestMaker documentation and example test agents show how to accomplish many of the most common tasks needed to test services for functionality, scalability and performance. There is also an active TestMaker support community. Plus, PushToTest Global Services provides TestMaker training for yourself and your team. And once mastering the scripting and TOOL objects will build your resume and experience. We believe it will be worth it!
And with that, the tutorial is concluded.
Ready for something different? Try one of these:
TestMaker Script Language Reference
Reference to the TOOL test object library
A guide to the example agents that come with TestMaker
A list of frequently asked questions
Building test agents to check email services for scalability and functionality
|