2013年1月20日 星期日

Robot Framework

 

 

Robot Framework 是一個自動測試框架

 

 

1. High-level architecture

NewImage

 

2.檔案架構

Test suit directly/ [subsuit directory | test case file] : include many test cases

                             /initialization file

 

建議的檔案目錄:

1.Test libraries:  lowest-level keywords

2.Resource files with variables and higher-level user keywords

3.Variable files to provide more flexible ways to create variables than resource files

 

3. Test data tables

Different test data tables
Table nameUsed forAliases
Setting table
2) Defining metadata for test suites and test cases
Setting, Settings, Metadata
Variable tableDefining variables that can be used elsewhere in the test dataVariable, Variables
Test case tableCreating test cases from available keywordsTest Case, Test Cases
Keyword tableCreating user keywords from existing lower-level keywordsKeyword, Keywords, User Keyword, User Keywords
 

 

4. Test setup and teardown

  Test setup:  Executed before a test case

  Teardown:  Executed after a test case

 

Test setup and teardown examples
SettingValueValueValue
Test SetupOpen ApplicationApp A 
Test TeardownClose Application  
Test CaseActionArgumentArgument
Default values[Documentation]Setup and teardownfrom setting table
 Do Something  
    
Overridden setup[Documentation]Own setup, teardownfrom setting table
 [Setup]Open ApplicationApp B
 Do Something  
    
No teardown[Documentation]Default setup, noteardown at all
 Do Something  
 [Teardown]  
    
No teardown 2[Documentation]Using special NONE,works with 2.5.6
 Do Something  
 [Teardown]NONE 
    
Using variables[Documentation]Setup and teardowngiven as variables
 [Setup]${SETUP} 
 Do Something  
 [Teardown]${TEARDOWN} 

 

5.Test case styles

*1.keyword-driven style

*2.data-driven style

*3.behaviro-driven style

 

6.Variable types:

*1 Scalar variables

It is possible to use list variables as scalar variables containing lists simply by replacing @ with $. This makes it possible to use list variables with list related keywords, for example, from BuiltIn and Collections libraries. This feature works only if there is no scalar variable with same base name as the list variable has. In these cases the scalar variable has precedence and its value is used instead.

Using list variables as scalars
Test CaseActionArgumentArgumentArgument
Example@{items} =Create Listfirstsecond
 Length Should Be${items}2 
 Append To List${items}third 
 Length Should Be${items}3 
 Remove From List${items}1 
 Length Should Be${items}2 
 Log Many@{items}  

*2 list variables: only can be used with some of settings

Using list variables with settings
SettingsValueValueComment
LibraryExampleLibrary@{LIB ARGS}# This works
Library${LIBRARY}@{LIB ARGS}# This works
Library@{NAME AND ARGS} # This does not work
Suite SetupSome Keyword@{KW ARGS}# This works
Suite Setup${KEYWORD}@{KW ARGS}# This works
Suite Setup@{KEYWORD} # This does not work
Default Tags@{TAGS} # This works

*3 environment variables

Environment variables set in the operating system before the test execution are available during it, and it is possible to create new ones with the keyword Set Environment Variable or delete existing ones with the keyword Delete Environment Variable, both available in the OperatingSystem library. Because environment variables are global, environment variables set in one test case can be used in other test cases executed after it. However, changes to environment variables are not effective after the test execution.

Using environment variables
Test CaseActionArgumentArgument
Env VariablesLogCurrent user: %{USER} 
 Run%{JAVA_HOME}${/}javac

 

 

 

Built-in variables

Available operating-system-related built-in variables
VariableExplanation
${CURDIR}An absolute path to the directory where the test data file is located. This variable is case-sensitive.
${TEMPDIR}An absolute path to the system temporary directory. In UNIX-like systems this is typically /tmp, and in Windows c:\Documents and Settings\<user>\Local Settings\Temp.
${EXECDIR}An absolute path to the directory where test execution was started from. New in Robot Framework 2.1.
${/}The system directory path separator. / in UNIX-like systems, \ in Windows.
${:}The system path element separator. : in UNIX-like systems and ; in Windows.

沒有留言:

如何下載Facebook 相簿跟影片

影片:透過chrome plug-in : Video Downloader for Facebook<sup>TM</sup> 相簿: 透過chrome plug-in : Tampermonkey 搭配script : Facebo...