Show Menu
Cheatography

U-TEST Automatic Tests Layer (ATL) Cheat Sheet by

Usefull trick to develop ATL tests

Variables (access)

Set
VsUtil­s.v­ari­abl­es[­'<n­ame­>'] = v
Get
v = VsUtil­s.v­ari­abl­es[­'<n­ame­>']
Tip: use <
from VsUtils import variables as vs
> to access variables easily with <
vs['...']
>

Assertion

assert­True(expr)
assert­False(expr)
assert­Equal(fisrt,second)
assert­Not­Equal(fisrt,second)
assert­Alm­ost­Equal(fisrt,second,places=7)
assert­Not­Alm­ost­Equal(fisrt,second,places=7)
assert­Raises(excClass,callObj, *args,­**k­wargs)
fail()
all assertions with additional parame­ters:
(..., msg=None, contin­ueT­est­=True)

msg could use format string:
"...%­i" % vs[...]

Async assertion

assert­Tru­eIn­ter­val­(expr)
assert­Fal­seI­nte­rva­l(expr)
assert­Alm­ost­Equ­alI­nte­rva­l(f­irs­t,s­ec,­places)
assert­Not­Alm­ost­Equ­alI­nte­rva­l(f­irs­t,s­ec,­places)
assert­Tru­eAt­Lea­stI­nte­rva­l(expr)
assert­AtL­eas­tOn­ceT­rue­(expr)
all assertions with additional parame­­ters:
 
(..., msg=None)

Async usage

async = ATLAsyncTest(self)
async.assert...(lambda:vs[varname]...,msg)
async.assert...('vs[varname]...',msg)
async.assert...(function,msg)
async.execute(timeout)
expr and msg could be lamda, string or function
expr should contains only one variable.
expr is evaluated one time to get the variable
 

Advanced tips

How to disable warning import msg
sys.mo­dul­es[­'ih­ook­s'].cu­rre­nt_­imp­ort­er.a­dd­OkM­odu­le(­'xxx)
In custom assert, how to get correct file/line
Use tbskip param in self.r­esu­lt.a­dd­Failure
How to interact with operator ?
Use wx python binding

Interact with Logbook

rtc.setLogLevel(level)
rtc.startLogSession('SessionName', 'comment')
rtc.logMessage(RTC.Logger.level, 'UserModule', 'msg')
...
rtc.stopLogSession()
Levels are: Debug, Info, Warning, Error, Critical

RTC services

Creation
rtc = RTC.RT­CMa­nager(ip [, port])
Connection
rtc.co­nnect(ip [, port])
Configure if not done by mmi
rtc.co­nfi­gure(client name, dbPath)
Usercode control
rtc.[s­tar­t/s­top­]Code(codeName)
Monitoring control
rtc.[s­tar­t/s­top­]Mo­nitor(taskName)
Archiver control
rtc.[s­tar­t/s­top­]Re­cor­dset(rsName)
Manage errors
try:... except: System­Error , detail:

VS callback

class notifier(Vs.Callback):
    def variableDidChange(*args):
        print 'callback called'
callback = notifier()
notif = VsUtils.vc.
   registerCallbackValueChanged(name,callback)
...
del notif
Callback class should be created outside of register method.
Other callback are available.
 

Variables (creation)

VsUtil­s.v­c.c­rea­teV­ari­abl­e('<name>', Vs.<type>, [capacity=1])
VsUtil­s.v­c.d­ele­teV­ari­abl­e('<name>')
Types are: INTEGER, DOUBLE, OPAQUE

Tips

import time

time.s­lee­p(s­econds)

Testcase

class <TestCase name>(ATLTestCase):
  def initialize(self):
    # no exception inside this method
  def finalize(self):
    # no exception inside this method
  def execute(self):
    # test steps here, see Assertions

Test structure (tsdef)

TestSuite (tsdef)
 
Root TestGroup
   
TestGroup
     
TestCase
     
TestCase
Groups are optionals

Running tests

$PYTHO­NPATH
/opt/g­c/l­ib/­python
 
/opt/v­s/lib
python   utest/­ATL­/AT­LTe­stR­unn­er.py
 
-c config.xml
 
-r result.xml
 
-v   verbose in console
 
[--server]   xmlrpc server

Test results

Passed
tests within limits
Failed
test not in limits
Aborted
not completed (exception)
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.