Robotframework 入门教程(三)
来源:互联网 发布:湖南纳米娱乐网络 编辑:程序博客网 时间:2024/05/20 11:25
==关键字==
RF中很关键的概念keyword,其实就是类似python中的方法。修改我们的demo.robot如下,
这个很好理解,就是定义一个Calcalate and Check方法两个参数,
相当于python中这样的一个方法:
second case中调用这个方法。关键字中如果有返回值,用[return] 关键字来表示,比如我们的关键字需要返回表达式的计算结果,就在最后加一行
Setting表用来导入Library,Resource, Variables,还有一些测试流程相关的东西,后面讲。
*** Settings ***[Documentation] Example test cases using the keyword-driven testing approach.*** Variables ***${var1} 1+2+3@{list1} a b c ${var1}&{dict1} key1=sf key2=${list1}*** Test Cases ***First Case Log to console ${var1} Log to console ${list1} Log to console ${dict1} Second Case Calculate and Check Equals ${var1} ${6}Third Case Calculate and Check Equals ‘i’*3 iii*** Keywords ***Calculate and Check Equals [Arguments] ${expression} ${expected} ${res}= Evaluate ${expression} Should Be Equal ${res} ${expected}
这个很好理解,就是定义一个Calcalate and Check方法两个参数,
相当于python中这样的一个方法:
def calculate_and_check_equals(expression, expected): res = eval(expression) assert res==expected
second case中调用这个方法。关键字中如果有返回值,用[return] 关键字来表示,比如我们的关键字需要返回表达式的计算结果,就在最后加一行
[return] ${res}这就是一个完整的testcase file了,包含了Settings,Variables,Test Cases,Keywords四个表。
Setting表用来导入Library,Resource, Variables,还有一些测试流程相关的东西,后面讲。
0 0
- Robotframework 入门教程(三)
- Robotframework 入门教程(一)
- Robotframework 入门教程(二)
- Robotframework 入门教程(四)
- Robotframework 入门教程(五)
- Robotframework 入门教程(六)
- Robotframework 入门教程(七)
- Robotframework 入门教程(八)
- Robotframework 入门教程(九)
- Robotframework 入门教程(十)
- RobotFrameWork(三)数据类型
- RobotFrameWork(三)数据类型
- CCV入门教程(三)
- Docker 入门教程(三)
- Maven 入门教程(三)
- Lucene入门教程(三)
- Cmake入门教程(三)
- Grunt入门教程之(三)
- PHP扩展插件imagick使用笔记
- SQL Server 2014内存优化表的使用场景_0
- Codeforces 615B - Longtail Hedgehog(DP)
- C语言之拼图1.0
- 大年三十,我又犯了哪些lua的错误
- Robotframework 入门教程(三)
- Ubuntu调出搜狗输入法
- [6]Linux文件编程
- Angular过滤器(filter)
- CodeForces - 733D Kostya the Sculptor (STL SET)
- 洛谷 1147_连续自然数和
- C++引用形参+模板---解决数组指针退化为指针
- SQL SERVER分区具体例子详解
- matlab str2double与str2num