python harness fundamental
DESCRIPTION
TRANSCRIPT
© 2011 LogiGear Corporation. All Rights Reserved
Python Harness in Python Harness in TestArchitectTestArchitect
Python Harness in Python Harness in TestArchitectTestArchitect
Created by: Han Trung TruongCreated by: Han Trung Truong
© 2011 LogiGear Corporation. All Rights Reserved
ContentContent
Introduction of HarnessPython harness installationPython harness contentHarness working on TestArchitectExampleDebug Python functions via Eclipse
© 2011 LogiGear Corporation. All Rights Reserved
Introduction of harnessIntroduction of harness
Interpretation of TestArchitect tests is a task of a "harness" A harness is a program or script that is able to interpret and execute
actions It can be implemented in a variety of scripting or programming
languages, like Python, Java, C#, C++, etc TestArchitect comes with a pre-built harness called
"taplayback.exe", but this is a binary that you can't modify
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
These are steps to setup/install Python harness:
1.Install python-2.6.6.msi
2.Install pywin32-214.win32-py2.6.exe
3.Install pycrypto-2.1.0.win32-py2.6.exe
4.Install MySQL-python-1.2.2.win32-py2.6.exe
5.Add “C:\Python26” to “Environment Variables” (System variables)
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
6. Launch “cmd.exe” window, change directory to “paramiko” folder, then install “paramiko” using python command
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
7. Extract “harness_CiscoSport.zip” to a folder on your system (i.e.: C:\harness_CiscoSport)
8. Edit the harness directory in “run.bat” file in “C:\harness_CiscoSport”
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
9. Finally point TA automation tool to the “run.bat” file
© 2011 LogiGear Corporation. All Rights Reserved
Python harness installationPython harness installation
Needed items are located in:
Item LocationEclipse \\192.168.170.177\Harness training\eclipse
Harness \\192.168.170.177\Harness training\harness_CiscoSport
Python installation \\192.168.170.177\Harness training\Python Installation.zip
TestArchitect 6.1.1.7 \\data-server\LogiGearVN\Test Architect builds\TANG Main Builds\Build 6.1\6.1.1.7
Document \\192.168.170.177\Harness training\Document
© 2011 LogiGear Corporation. All Rights Reserved
Python harness contentPython harness content
Harness Folder contains two main items: “run.bat” file and “src” folder. “run.bat” file is an Automation Tools and specified on the first
run or debugging test. “src” folder contains sub folders:
• “Python” including main TA libraries and classes• “user” consisting of libraries, classes and modules created
by users.
© 2011 LogiGear Corporation. All Rights Reserved
Harness working on TestArchitectHarness working on TestArchitect
When executing TMs, TA compiles and stores data in text files at: C:\Documents and Settings\All Users\Application Data\LogiGear\TestArchitect\Data\SERVERS\{TA
project ID}\files\{TM Name} on XP
C:\Users\Public\ LogiGear\TestArchitect\Data\SERVERS\{TA project ID}\files\{TM Name} on Win 7 and Vista
Theses files contain all actions that we wrote in scripts.
Harness have to start its execution from main.py file.
After the execution, name of the executed text file will be displayed at “test file name” setting of run.dat file (which is located in C:\Documents and Settings\All Users\Application Data\LogiGear\TestArchitect)
© 2011 LogiGear Corporation. All Rights Reserved
Harness working on TestArchitectHarness working on TestArchitect
© 2011 LogiGear Corporation. All Rights Reserved
ExampleExample
The py file containing harness actions must have 2 main functions SetActions() and Divert(actionName). Below is an example of “mod_Actions.py” file.
def SetActions(): module = "actions" LIBRARY.SetActionScript("enter value", module, 1) LIBRARY.SetActionScript("check url", module, 1)
def Divert(actionName): result = True if actionName == "enter value": action_entervalue() elif actionName == "check url": action_checkurl() else: result = False LIBRARY.ReportError("Don't know action: " + actionName) return result
"actions" is name of the module; “enter value” and “check url” are the action name used in TA
action_entervalue() and action_checkurl() are two functions created within the module. If any additional functions are created, their information must be set and diverted in SetActions() and Divert() functions.
© 2011 LogiGear Corporation. All Rights Reserved
To debug action via Eclipse we need to compile TM that contains the action in TA to create file text.
Open Eclipse and find function that you want to debug, set breakpoint.
Open main.py file, right click and select debug as -> python run
When Harness run it will stop at the break point. Press F5 (go to next function) or F6 (step into function) to
debug line by line and see value return in Eclipse.
Debug Python functions via EclipseDebug Python functions via Eclipse
© 2011 LogiGear Corporation. All Rights Reserved
Thank you