创建自定义测试库


创建自定义测试库

自定义库MyLib.py

class MyLib(object):

    ROBOT_LIBRARY_VERSION = 1.0

    def __init__(self):
        pass

    def test1(self):
        print('test1')
    def test2(self):
        return 'test2'
    def test3(self, name):
        print(name)
    def test4(self, name):
        return name
    def test5(self, name='tom', age=20):
        print(name+','+str(age))
    def test6(self, *args):
        for x in args:
            print(x)
    def test7(self, **kwargs):
        for item in kwargs.items():
            print(item)
    def test8(self, a=10, b=100):
        return random.randint(a, b)

测试用例

*** Settings ***
Library    MyLib.py    
*** Test Cases ***
case01
    Test1
    Test2
    Test3    tom
    ${res}    Test4    tom
    Test5
    Test6    tom    kite    rose
    Test7    name=tom    age=20    email=tom@email.com
    ${res}    Test8