Robot framework使用Sample

1、quick start

我们以python为例,写几个keyword,然后根据keyword编写test cases;执行case。

(1)write keyword

新建一个ExampleLibrary.py,代码如下:

def simple_keyword(): \ print 'You have used the simplest keyword.' def greet(name): \ print 'Hello %s!' % name def multiply_by_two(number): \ The result is always a floating point number. This keyword fails if the given `number` cannot be converted to number. \ return float(number) * 2 def numbers_should_be_equal(first, second): print '*DEBUG* Got arguments %s and %s' % (first, second) if float(first) != float(second): raise AssertionError('Given numbers are unequal!') (2)编写html格式的test cases

用RIDE可以很轻松的编写

(3)执行:

pybot example_tests.html

(4)查看日志:

2、keywords

(1)内置keyword

例如, 验证 (e.g. Should Be Equal, Should Contain), 转换(e.g. Convert To Integer) 以及其他的 (e.g. Log, Sleep, Run Keyword If, Set Global Variable).

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4