python--应用场景--Robot Framework

一、环境搭建

  1. 安装:pip install robotframework
  2. 官方文档: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

python--应用场景--Robot Framework_第1张图片

HTML格式测试报告

python--应用场景--Robot Framework_第2张图片

python--应用场景--Robot Framework_第3张图片

python--应用场景--Robot Framework_第4张图片

 

转载于:https://my.oschina.net/u/3323607/blog/2461877

你可能感兴趣的:(python--应用场景--Robot Framework)