Automation One By One - Robot Framework - Conception

上一篇 / 下一篇  2011-07-04 18:17:38 / 个人分类:Robot Framework

手动测试过程中,有Test Case(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
Setting table
2) Defining metadata fortest cases
Variable tableDefiningvariables
that can be used elsewhere in the test case
Test case tableCreating test casesfrom available keywords
Keyword tableCreating user keywordsfrom existing lower-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 suite created 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
Setting table
2) Defining metadata fortest suite
Variable tableDefiningvariables
that can be used elsewhere in the test case
Keyword tableCreating user keywordsfrom existing lower-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 OperatingSystem
Suite Setup Start Selenium Server
Force Tagsexample


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


***Keywords***

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



TAG:

spo22的个人空间 引用 删除 spo22   /   2012-12-01 02:59:35
Automation One By One - Robot Framework 这个系列写得真不错,谢谢分享。
spo22的个人空间 引用 删除 spo22   /   2012-12-01 02:59:07
5
 

评分:0

我来说两句

Open Toolbar