zoukankan      html  css  js  c++  java
  • RF中导入扩展库以及它的的搜索规则

    Python作为测试库

      模块文件名作为测试库的名字

           比如Python模块名叫MyLib,对应的Python文件是MyLib.py,测试库的名字就是MyLib

      定义在Python模块文件名的函数,名称前有_前缀的不会作为关键字

     模块.函数:

        导入测试库方式 :模块名(导入测试库,函数名对应关键字)

        tlib.py

     def retlist(self):
         return 11
     def _retlist2(self):
         return 22

      test.robot

    *** Settings ***
    Library   tlib.py
    
    *** Test Cases ***
    case1
        ${ret}  retlist  
        log to console  ${ret}

        类.方法:

      导入测试库方式 :模块名.类名(导入测试库,方法名对应关键字)

      tlib.py

    class Tlib():
        def retlist(self):
            return 33
        def _retlist2(self):
            return 44

      test.robot

    *** Settings ***
    Library   tlib.Tlib
    
    *** Test Cases ***
    case1
        ${ret}  retlist
        log to console  ${ret}

     

    总结: 

    定义在Setting表,全局配置表中,和python的模块规则一样

    1.声明测试库:模块导入法和路径导入法

    Library   pylib.testlib

    Library   pylib/testlib.py

    2.声明资源文件

    Resource  rc.robot

    3.声明变量文件(一般定义常量)

    Variables  test/cfg.py

    不同于全局变量表,定义在Variables:

    *** Variables ***
    @{list}  '192.168.1.12'  '80'

     python库中class存在继承,父类和子类都会初始化

  • 相关阅读:
    ubuntu安装
    学习资料

    disksim-3.0 with flashsim 安装
    STL
    存储引擎
    数据库索引
    数据库表、字段设计
    查询SQL优化
    导航栏实现
  • 原文地址:https://www.cnblogs.com/Lara1798/p/12951364.html
Copyright © 2011-2022 走看看