robotframework timeout的用法

2018-10-10  本文已影响0人  tafanfly

timeout

测试case有时候会莫名其妙的卡住, 导致整个job跑不下去,所以需要给case增加个timeout的参数

image.png

函数Start Global Timer如下:

from threading import Timer
from robot.libraries.BuiltIn import BuiltIn

def start_global_timer(timeout):
    BuiltIn().log('Start global timer, timeout is %s seconds.' % timeout, level='WARN')
    t = Timer(float(timeout), interrupt_pybot)
    t.setDaemon(True)
    t.start()

def interrupt_pybot():
    import thread
    thread.interrupt_main()
    BuiltIn().log('The job execution is timeout, stop it forcibly.', level='WARN')
上一篇下一篇

猜你喜欢

热点阅读