上一节咱们已经介绍 Robot Framework-RIDE 只支持 Python2 ,但 Python2 到 2020 年将再也不维护,因此接下来的关于 Robot Framework 的学习将再也不基于 Robot Framework-RIDE,你能够参考上一节中介绍的 Sublime Text3 + sublime-robot-framework-assistant 插件来编写 Robot Framework 脚本。html
建立测试
-
测试项目(目录): rf_test/浏览器
-
测试套件(文件): test_suit.robotbash
-
测试用例 (test_suit.robot文件中代码):post
*** Test Cases ***
test case1 log hello robot framework
运行测试
Robot Framework 运行测试经过 pybot
命令,检查 _C:\Python36\Scripts_ 目录下是否有 pybot.bat 文件,正确安装 Robot Framework 必定会生成该文件。 _C:\Python36\Scripts_ 目录必定要添加环境变量 path。学习
打开cmd Window 命令提示符,切换到 Robot Framework 项目目录。测试
- 运行一条用例:
...\rf_test> pybot --test test_case test_suit.robot
- 运行指定文件:
...\rf_test> pybot test_suit.robot
- 运行当前目录下以.robot为后缀名的测试文件
...\rf_test> pybot *.robot
- 运行当前test_a目录下的全部用例
...\rf_test> pybot test_a
- 运行当前目录下的全部以.robot为后缀名的测试文件
...\rf_test> pybot ./
生成测试报告
当经过上面的命令运行测试,Robot Framework 会自动帮咱们生成测试报告。ui
D:\rf_test > pybot test_suit.robot
==============================================================================
Test Suit
==============================================================================
test case1 | PASS | ------------------------------------------------------------------------------ Test Suit | PASS | 1 critical test, 1 passed, 0 failed 1 test total, 1 passed, 0 failed ============================================================================== Output: D:\rf_test\output.xml Log: D:\rf_test\log.html Report: D:\rf_test\report.html
当用例运行结束,Robot Framework 生成三个文件:output.xml、log.html 和 report.html。spa
output.xml 记录的测试结果是 XML 文件。根据特定的须要能够编写脚本读取 XML 文件并生成特定的测试报告。插件
log.html 会记录 Robot Framework 运行的每一步操做,主要用于编写测试脚本的过程当中查看。
report.html 为测试报告,整理性的展现测试用例的运行状况。
经过浏览器打 log.html 文件查看。
怎么样,相信经过这一节的学习,你已经学会了 Robot Framework 基本使用。