环境&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
选择要执行的用例
–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
- 输出结果:
合并多次执行结果
- –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