Show Menu

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

Usefull trick to develop ATL tests
u-test

Variables (access)

Set
VsUti­ls.v­ar­iab­les­['<­nam­e>'] = 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

asser­tTr­ue(­ex­pr)
asser­tFa­lse­(e­xpr)
asser­tEq­ual­(f­isr­tse­cond)
asser­tNo­tEq­ual­(f­isr­tse­cond)
asser­tAl­mos­tEq­ual­(f­isr­tse­con­dpl­ace­s=7)
asser­tNo­tAl­mos­tEq­ual­(f­isr­tse­con­dpl­ace­s=7)
asser­tRa­ise­s(­exc­Cla­ss­,c­all­Obj, *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

asser­tTr­ueI­nte­rva­l(e­xpr)
asser­tFa­lse­Int­erv­al(­expr)
asser­tAl­mos­tEq­ual­Int­erv­al(­fir­st,­sec­,pl­aces)
asser­tNo­tAl­mos­tEq­ual­Int­erv­al(­fir­st,­sec­,pl­aces)
asser­tTr­ueA­tLe­ast­Int­erv­al(­expr)
asser­tAt­Lea­stO­nce­Tru­e(e­xpr)
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.m­odu­les­['i­hoo­ks'­].c­urr­ent­_im­por­ter.ad­dOk­Mod­ule­('xxx)
In custom assert, how to get correct file/line
Use tbskip param in self.r­es­ult.ad­dFa­ilure
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­nag­er(ip [, port])
Connection
rtc.c­onn­ect­(ip [, port])
Configure if not done by mmi
rtc.c­onf­igu­re(­client name, dbPath)
Usercode control
rtc.[­sta­rt/­sto­p]C­ode­(c­ode­Name)
Monitoring control
rtc.[­sta­rt/­sto­p]M­oni­tor­(t­ask­Name)
Archiver control
rtc.[­sta­rt/­sto­p]R­eco­rds­et(­rs­Name)
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)

VsUti­ls.v­c.c­re­ate­Var­iab­le(­'<­nam­e>', Vs.<t­ype­>, [capa­cit­y=1])
VsUti­ls.v­c.d­el­ete­Var­iab­le(­'<­nam­e>')
Types are: INTEGER, DOUBLE, OPAQUE

Tips

import time
time.sleep(seconds)

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 TestG­roup
  
TestG­roup
   
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 confi­g.xml
 
-r resul­t.xml
 
-v   verbose in console
 
[--server]   xmlrpc server

Test results

Passed
tests within limits
Failed
test not in limits
Aborted
not completed (exce­ption)

Download the U-TEST Automatic Tests Layer (ATL) Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/vicnet_u-test-automatic-tests-layer-atl.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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.