Robot Framework 转

上一篇 / 下一篇  2012-08-01 18:13:49 / 个人分类:Robot framework

手动测试过程中,有TestCase(Test Environment,Test Data,Test Steps, Expected Result), Test Suite的概念;软件开发过程上有面向对象的概念(即继承、封装,多态),做自动化测试开发需要具备测试人员的基础知识及程序员的思想。

1. Test Case - 包含测试数据,一系列的操作步骤及期望值。
  • 写Test Case时,可以使用4种格式,分别是hypertext markup language (HTML), tab-separated values (TSV),plain text, or reStructuredText (reST) formats,本实例中使用plain text的格式。
  • Plain text格式的Test Case使用至少2个空格做为分隔符。
  • 因为空格作为分隔符使用,当需要使用空格原义时,可以使用${EMPTY}变量或是 \ 来进行转义。
  • 组成Test Case的要素
    • 操作步骤(Test Steps)- Action (用Keyword来实现)
    • 期望值(Expected Result)- Argument(可以使用Variable)
    • 测试数据(Test Data)- Argument
    • Example:
***Test Cases***
My Test [Documentation] Example test
Log ${MESSAGE}

Another Test
Should Be Equal ${MESSAGE} Hello, world!

My Test/Another Test 是Test Case的名字
Log/Should Be Equal - 是Action(Keywords)
${Message}/Hello, world - 是期望值(可以是变量也可以是常量)
2. 多个Test Cases可以放在同一个文件中,称为test case file。
  • Test Case File的组成
Table nameUsed for
Settingtable
2) Defining metadata fortest cases
VariabletableDefiningvariables
that can be usedelsewhere in the test case
Test casetableCreating test casesfrom availablekeywords
KeywordtableCreating user keywordsfrom existinglower-level keywords
  • Examples:
***Settings***
Library     OperatingSystem

***Variables***
${MESSAGE}  Hello, world!

***Test Cases***
My Test  [Documentation]  Example test
Log         ${MESSAGE}
My Keyword  /tmp

Another Test
Should Be Equal  ${MESSAGE}  Hello, world!

***Keywords***

My Keyword  [Arguments]  ${path}
Directory Should Exist  ${path}

3. Test Suite - A test suite created from a directory can have similar settings as a suitecreated from a test case file。
  • 1个或多个具有相同设置的Test Case File可以组成一个Test Suite, 多个Test Suites可以组成另一个更高层的Test Suite。
  • Test Suite中的Test case file可以通过在名称中添加数字来进行排序,如01__some_tests.txtand02__more_tests.txt。
  • 每层次Test Suites中都应该包含一个初始化文件,即以__init__.txt命名的文件(从Python语法中借鉴而来)。
  • 初始化文件的内容与Test case file文件中的内容基本相同,除了不支持test case table及一部分的settings table内容。
Table nameUsed for
Settingtable
2) Defining metadata fortest suite
VariabletableDefiningvariables
that can be usedelsewhere in the test case
KeywordtableCreating user keywordsfrom existinglower-level keywords

  • 初始化文件主要作用是把具有相同Settings的test case file聚集在一起。
  • 初如化文件中的主要内容:
    • Documentation/Metada
    • Suite Setup,Suite Teardown
    • Test Setup,Test Teardown
    • Force Tags,
    • Default Tags,Test Template,Test Timeout - Not supported
  • Examples:
***Settings***
Library     OperatingSystemSuite Setup     StartSeleniumServerForce Tagsexample


***Variables***
${MESSAGE}  Hello, world!


***Keywords***

My Keyword  [Arguments]  ${path}
Directory Should Exist  ${path}


TAG:

 

评分:0

我来说两句

日历

« 2024-04-24  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 19018
  • 日志数: 32
  • 建立时间: 2012-03-07
  • 更新时间: 2013-11-03

RSS订阅

Open Toolbar