一、环境搭建
- 安装:pip install robotframework
- 官方文档:http://robotframework.org/robotframework/#standard-libraries
二、应用举例
python脚本:RobotFrameworkDemo.py
#!/usr/bin/env python
class RobotFrameworkDemo(object):
def __init__(self,):
pass
def add(self,a,b):
return a + b
def minus(self,a,b):
return a - b
if __name__ == "__main__":
pass
测试案例集文件:test.robot
*** Settings ***
Documentation
... RobotFramework框架应用举例
...
Library RobotFrameworkDemo
*** Variables ***
${MESSAGE} Hello, world!
*** Test Cases ***
用例一:测试add方法
${RESULT1} = add ${1} ${2}
Should Be Equal ${RESULT1} ${3}
用例二:测试minus方法
${RESULT2} = minus ${3} ${1}
Should Be Equal ${RESULT2} ${2}
用例三:测试Hello,world变量
Should Be Equal ${MESSAGE} Hello, world!
*** Keywords ***
My Keyword
[Arguments] ${path}
Directory Should Exist ${path}
运行:robot test.robot
HTML格式测试报告