1、Robot Framework库的路径

     Lib\site-packages\robot\libraries

2、自定义用户库

     1、Lib\site-packages 添加  MyLibrary

  2、  MyLibrary添加count.py

#coding=utf-8
class Count(object):
    def add(self, a, b):
        '''
        用于计算a、b两数相加的结果,例:
        | add | a | b |		
        '''
        return int(a) + int(b)

    def sub(self, a, b):
        '''
        用于计算a、b两数相加的结果,例:
        | add | a | b |
        '''
        return int(a) - int(b)

  

     3、MyLibrary添加__init__.py

#coding=utf-8
from MyLibrary.count import Count

__version__='1.0'

class MyLibrary(Count):
	ROBOT_LIBRARY_SCOPE='GLOBAL'

测试:

      

*** Settings ***
Library           MyLibrary

*** Keywords ***
system
    [Documentation]    系统类型
    ${a}=    add    1    2
    log    ${a}

cpu
    ${a}=    sub    2    1
    log    ${a}
Starting test: Workspace.Mdoule.SysInfo.Demo1.test1
20211108 14:51:05.732 :  INFO : ${a} = 3
20211108 14:51:05.734 :  INFO : 3
20211108 14:51:05.739 :  INFO : ${a} = 1
20211108 14:51:05.741 :  INFO : 1
Ending test:   Workspace.Mdoule.SysInfo.Demo1.test1

 

 

posted on 2021-11-08 15:00  Old-Kang  阅读(81)  评论(0编辑  收藏  举报