执行robotframework脚本常用参数

环境&robot、rebot命令

  • 环境 rf 3.2.2,python3.6
  • robot:用于执行脚本
  • rebot:对生成的报告进行处理

测试数据

  • suites是测试套件集合的目录,下级有suite_test.robobt,suite_test2.robobt测试套件
  • suite_test.robot中三个测试用例分别是test_case1,test_case2,new_keywords
    rf脚本

选择要执行的用例

–test(-t):指定执行的用例

  • 用法:-t, --test ,name支持正则
robot --test test_case2 suite_test.robot  #只执行test_case2用例
robot --test test_* suite_test.robot  #执行suite_test.robot中test_开头的用例

–suite(-s):指定执行的测试套件,参数是套件名

  • 用法:-s, --suite
    robot --suite suites.suite_test . #只执行suites中的suite_test套件中的用例

–include(-i) :通过tag指定要执行的用例,参数是标签名

  • 用法: -i, --include
robot --include case_tag1 suite_test.robot  #只执行suite_test.robot中有case_tag1标签的用例

–exclude(-e):通过tag指定不要执行的用例,参数是标签名

  • -e, --exclude
  • 用法:同–include

添加模块搜索路径

  • 用法:–pythonpath(-P) path
robot -P . -t testcase test.robot  #将当前目录设置为模块搜索路径

添加变量文件

  • 用法:-V, --variablefile path:args
--variablefile semyvariables.py
--variablefile path/variables.py
--variablefile /absolute/path/common.py
--variablefile taking_arguments.py:arg1:arg2

使用

robot --variablefile test_var.py:11  Login.robot

执行失败用例重跑

–rerunfailed(-R):重新执行失败的用例,参数是执行结果文件

  • 用法: -R, --rerunfailed <output_file>
robot --rerunfailed ouput.xml suite_test.robot #执行suite_test.robot套件中执行失败的用例

-rerunfailedsuites(-S):重新执行失败的测试套件

  • 用法: -S, --rerunfailedsuites <output_file>, 同–rerunfailed

–critical(-c):设置重要用例

  • 用法:-c, --critical
robot --critical case-tag1 suite_test.robot #将case_tag1标签的用例标记为重要

–noncritical(-n): 设置不重要用例

  • 用法:-n, --noncritical ,同–critical

设置输出文件的目录和名称

–outputdir(-d):输出文件的目录

  • 用法: -d, --outputdir
robot  --outputdir result_test suite_test.robot

输出结果

–output(-o):输出文件,默认为output.xml

  • 用法: -o, --output
  • 如果不需要输出则设置–output NONE
robot  --output reset_output.xml suite_test.robot

在这里插入图片描述

–report(-r):设置输出的报告文件,输出的文件名,默认为report.html

  • 用法:同–output
  • 如果参数是NONE(–report NONE)则不输出报告

–log(-l):设置输出的日志文件,输出的文件名,默认为log.html,

  • 用法:同–output
  • 如果参数是NONE(–log NONE)则不输出日志

–logtitle:设置输出的日志文件html中的title

  • 用法: --logtitle
robot  --logtitle  "suite_test测试结果" suite_test.robot    #设置日志文件中的title为"suite_test测试结果"

–reporttitle:设置输出的报告文件html中的title

  • 用法:同–logtitle

–timestampoutputs(-T):为输出的文件自动添加时间戳

robot  --output reset_output.xml --timestampoutputs suite_test.robot
  • 输出结果:
    在这里插入图片描述

查看debug内容

  • –debugfile(-b):输出调试文件,参数是需要保存的调试文件名
  • 用法:–debugfile
robot  --debugfile debug  suite_test.robot
  • 输出结果:
    debugfile

合并多次执行结果

  • –merge(-R):将重新执行的结果和原结果合并
  • 用法: -R, --merge <xml_file>
rebot output1.xml output2.xml #将output1.xml和 output2.xml合并输出测试报告

学习资料:http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#task-execution
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#id921

  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值