r3 - 19 Jul 2007 - 06:24:02 - MimiYinYou are here: OSAF >  Journal Web  >  QualityAssuranceTeam > AdamChristianNotes > AdamChristianTestRunner
Test Runner

The goal of this script is to allow you to run all of the tests from the command line by providing the needed parameters.
One of the more important features to this script is that you provide it the full file path and it will import the file as a string and execute it as python, this is convenient because you don't have to rely on python to import the file, which is difficult when these tests are in different places on the file system.

The below comments at the top of TESTRunner.py should explain all the available parameters.

# This is the test runner script, its used to run cosmo and scooby tests using cmp and json-rpc
#
# Example:  
# adam$ python TESTRunner.py file=scoobyCalendarStress.py classname=scoobyCalendarStress recurrence=10 debug=0
#
# Available Parameters:
#
# host - Location of cosmo server with scooby instance, defaults localhost
# port - The port its running, defaults to 8080
# path - This is the url path to either /cosmo or /scooby. Defaults to /scooby
# recurrence - This is how many times its going to execute. (add 100 events, or calendars etc. depending on the test.) defaults 0
# debug - this defines the level of output, defauts to 0
# file - The path to the file where the tests is located. (ie /Users/adam/Documents/scoobytests/mytest.py)
# classname - The class in that file you will be instantiating to run the test: scoobyCalendarStress.py

if __name__ == "__main__":
    
    #host, port, path, username, password, debug
    #TestFile, class
    import sys
    import string
    
    #Set the cosmo server, and scooby path
    host = 'localhost'
    port = '8080'
    path = '/scooby'
    
    #Set the target user
    #username = 'scoobyTest'
    #password = 'scoobyTest'
    
    #Set your debug
    debug = 0
    recurrence = 0
    
    for arg in sys.argv:
        args = arg.split("=")
        if args[0] == "host":
            host = args[1]
        elif args[0] == "port":
            port = int(args[1])
        elif args[0] == "path":
            path = args[1]
        elif args[0] == "recurrence":
            recurrence = int(args[1])
        elif args[0] == "debug":
            debug = int(args[1])
      #  elif args[0] == "username":
      #      username = args[1]
     #   elif args[0] == "password":
     #       password = args[1]
        elif args[0] == "file":
            file = args[1]
        elif args[0] == "classname":
            classname = args[1]
    
    #Append py if the tester forgets
    if string.find(file, ".py") == -1:
        file = '%s.py' % (file)
    
    f = open(file)
    classToRun = f.read()
    exec (classToRun)
    
   # instantiationString = ("%s=%s(host='%s', port='%s', path='%s')" % (classname, classname, host, port, path))
    instantiationString = '%s = %s(host="%s", port=%s, path="%s")' % (classname, classname, host, port, path)
    exec (instantiationString)
    #set other params
    #setUsername = "%s.username = '%s'" % (classname, username)
    #exec (setUsername)
    #setPassword = "%s.password = '%s'" % (classname, username)
    #exec (setPassword)
    setDebug = "%s.debug = %i" % (classname, debug)
    exec (setDebug)
    setRecurrence = "%s.recurrence = %i" % (classname, recurrence)
    exec (setRecurrence)
    doFullrun = "%s.fullRun()" % (classname)   
    exec(doFullrun) 
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r3 < r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.