Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [maxq-dev] Thoughts on recorded scripts

maxq
Discussion topic

Back to topic list

[maxq-dev] Thoughts on recorded scripts

Author fcohen
Full name Frank Cohen
Date 2004-09-15 13:09:34 PDT
Message I'm doing some work on TestMaker and wanted to share this with you in
hopes that it influences the future of MaxQ positively. A few TestMaker
users have urged me to adopt jUnit TestCases as the standard output of
the TestMaker recorder (which is based on an older MaxQ version.)

I looked at the output of MaxQ v94. It seems to me that the scripts are
getting a little verbose. I'm not sure why there is such a need to
Validate so many things. The class generated should include some
information about the test, including the number of gets/posts
processed. There should be a logging-level allowed so I can dynamically
turn on/off debug comments. Lastly, I like the idea of using TOOL, the
protocol handler library in TestMaker, so that I could substitute the
underlying http protocol handler. For example, to see the difference in
performance between Apache HTTP Client and Java HTTPUrlConnection.

I did some reading and mocked-up a functional test script that
implements a TestCase. I am seeking feedback, comments, and criticism
on this from the TestMaker developer community
(dev at lists dot pushtotest dot com) and would also like any MaxQ feedback.

Here is the mock-up of a recorded script:

'''
Agent name: mytest.py
Created by: TestMaker Agent Recorder
Created on:

Purpose:
Calculates a Transaction-Per-Second index for a
Web-enabled HTTP application

For details on TestMaker see http://www.pushtotest.com
'''

from com.pushtotest.tool.​protocolhandler import ProtocolHandler,
HTTPProtocol
from com.pushtotest.tool.response import Response
from java.util import Date
from java.lang import Exception
from junit.framework import TestCase

'''
The test class implements the steps recorded while watching a user
operate the application using a browser.
'''

class mytest:

     def __init__( self, loglvl = 0 ):
         ''' Initialization '''
         self.loglevel = loglvl
         if self.loglevel > 0:
             print "mytest: Initialize"
         self.steps = 0 # Counter of steps in transaction
         self.http = ProtocolHandler.getP​rotocol("http")

     def setUp( self ):
         ''' Add any needed set-up code here. '''
         if self.loglevel > 0:
             print "mytest: setUp"
         pass

     def runTest( self ):
         ''' Run the test '''
         if self.loglevel > 0:
             print "mytest: runTest"

         self.http.setUrl(
'''http://examples.push​totest.com/responder​/htmlresponder?
file=file1.html''' )
         self.http.setType( HTTPProtocol.GET )
         self.response = self.http.connect()
         TestCase.assertEquals("Step 1 failed while trying to get: '" + \
         self.http.getURL("http"), 200, self.response.getResponseCode() )
         self.logit()

         self.http.setUrl(
'''http://examples.push​totest.com/responder​/htmlresponder''' )
         self.http.setType( HTTPProtocol.POST )
         self.body = ProtocolHandler.getBody( 'http' )
         self.http.setBody( self.body )
         self.body.addParamet​er('''firstname''', '''frank''')
         self.body.addParamet​er('''lastname''', '''cohen''')
         self.body.addParamet​er('''phone''', '''''')
         self.body.addParamet​er('''account''', '''''')
         self.body.addParamet​er('''amount''', '''''')
         self.body.addParamet​er('''Transfer''', '''Transfer Funds''')
         self.response = self.http.connect()
         TestCase.assertEquals("Step 2 failed while trying to post: '" +
self.http.getURL("http"), 200, self.response.getResponseCode() )
         self.logit()

         self.http.setUrl(
'''http://examples.push​totest.com/responder​/htmlresponder?
file=file3.html''' )
         self.http.setType( HTTPProtocol.GET )
         self.response = self.http.connect()
         TestCase.assertEquals("Step 3 failed while trying to get: '" +
self.http.getURL("http"), 200, self.response.getResponseCode() )
         self.logit()

     def logit( self ):
         self.steps += 1
         if self.loglevel > 1:
             print "mytest: runTest, step", self.steps

     def tearDown( self ):
         ''' Add any needed code to end the test here. '''

     def setLoglevel( self, loglv ):
         self.loglevel = loglv
     def getLogLevel( self ):
         return self.loglevel
     def getSteps( self ):
         return self.steps

# Code to instantiate and run the test

if __name__ == 'main':

     print "===================​====================​================"
     print " myTest.py: Functional test of a Web application "
     print "===================​====================​================"
     print "Test recorded by TestMaker from http://www.pushtotest.com"
     print

     test = mytest( 2 ) # Value determines logging level, 0 =
off, 1 = Major messages only, 2 = Step details
     test.runTest()

     print "Test executed", test.getSteps(), "steps."
     print "Test completed."


---
Frank Cohen, PushToTest, http://www.PushToTest.com, phone: 408 374 7426
Author of "Java Testing and Design: From Unit Tests to Automated Web
Tests"
from Prentice Hall, details at http://thebook.pushtotest.com


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: dev-unsubscribe at maxq dot tigris dot org
For additional commands, e-mail: dev-help at maxq dot tigris dot org

« Previous message in topic | 1 of 12 | Next message in topic »

Messages

Show all messages in topic

[maxq-dev] Thoughts on recorded scripts fcohen Frank Cohen 2004-09-15 13:09:34 PDT
     Re: [maxq-dev] Thoughts on recorded scripts oliverbock Oliver Bock 2004-09-15 15:15:34 PDT
         Re: [maxq-dev] Thoughts on recorded scripts fcohen Frank Cohen 2004-09-16 22:35:35 PDT
             Re: [maxq-dev] Thoughts on recorded scripts Oliver Bock <oliverbock at swiftdsl dot com dot au> Oliver Bock <oliverbock at swiftdsl dot com dot au> 2004-09-16 23:42:36 PDT
                 Re: [maxq-dev] Thoughts on recorded scripts fcohen Frank Cohen 2004-09-17 07:11:46 PDT
                     Re: [maxq-dev] Thoughts on recorded scripts avery1701 Matt Avery 2004-09-17 08:56:28 PDT
                 Re: [maxq-dev] Thoughts on recorded scripts hdara at primavera dot com hdara at primavera dot com 2004-09-17 10:10:14 PDT
                     Re: [maxq-dev] Thoughts on recorded scripts fcohen Frank Cohen 2004-09-17 11:10:34 PDT
                         Re: [maxq-dev] Thoughts on recorded scripts hdara at primavera dot com hdara at primavera dot com 2004-09-17 11:18:35 PDT
     Re: [maxq-dev] Thoughts on recorded scripts avery1701 Matt Avery 2004-09-15 18:55:13 PDT
         Re: [maxq-dev] Thoughts on recorded scripts Oliver Bock <oliverbock at swiftdsl dot com dot au> Oliver Bock <oliverbock at swiftdsl dot com dot au> 2004-09-15 19:03:26 PDT
         Re: [maxq-dev] Thoughts on recorded scripts fcohen Frank Cohen 2004-09-16 22:37:11 PDT
Messages per page: