Robot Framework 是一個自動測試框架
1. High-level architecture
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
Table name | Used for | Aliases |
---|---|---|
Setting table | 2) Defining metadata for test suites and test cases | Setting, Settings, Metadata |
Variable table | Defining variables that can be used elsewhere in the test data | Variable, Variables |
Test case table | Creating test cases from available keywords | Test Case, Test Cases |
Keyword table | Creating user keywords from existing lower-level keywords | Keyword, Keywords, User Keyword, User Keywords |
4. Test setup and teardown
Test setup: Executed before a test case
Teardown: Executed after a test case
Setting | Value | Value | Value |
---|---|---|---|
Test Setup | Open Application | App A | |
Test Teardown | Close Application |
Test Case | Action | Argument | Argument |
---|---|---|---|
Default values | [Documentation] | Setup and teardown | from setting table |
Do Something | |||
Overridden setup | [Documentation] | Own setup, teardown | from setting table |
[Setup] | Open Application | App B | |
Do Something | |||
No teardown | [Documentation] | Default setup, no | teardown 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 teardown | given 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.
Test Case | Action | Argument | Argument | Argument |
---|---|---|---|---|
Example | @{items} = | Create List | first | second |
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
Settings | Value | Value | Comment |
---|---|---|---|
Library | ExampleLibrary | @{LIB ARGS} | # This works |
Library | ${LIBRARY} | @{LIB ARGS} | # This works |
Library | @{NAME AND ARGS} | # This does not work | |
Suite Setup | Some 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.
Test Case | Action | Argument | Argument |
---|---|---|---|
Env Variables | Log | Current user: %{USER} | |
Run | %{JAVA_HOME}${/}javac |
|
Built-in variables
Variable | Explanation |
---|---|
${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. |
沒有留言:
張貼留言