forked from adrianyorke/robotframework-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
recipe021_explaining_variable_prefixes.robot
52 lines (47 loc) · 1.96 KB
/
recipe021_explaining_variable_prefixes.robot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
*** Settings ***
Documentation PROBLEM:
... You are confused by variable prefixes in Robot Framework and don't know which
... one to use and when.
... DISCUSSION:
... This is a common problem for test engineers new to Robot Framework but it's not
... difficult once you understand what each prefix does.
... Run this recipe and closely examine the results in the log.
... Scalar variables start with $ prefix and should be considered a single value.
... The @ prefix is similar to the * (expansion or unpacking) operator in Python.
... Ruby and Perl developers will be familiar with the term "splat".
... JavaScript community will know this as the spread operator.
... This recipe also demonstrates how to create your own user keywords and use
... these in your test cases without needing to create lower level library keywords
... using Java or Python.
... SEE ALSO:
... BuiltIn library also has keywords for creating lists and dictionaries, checking
... length or count and checking membership or equality.
Library Collections
*** Variables ***
${recipe} Recipe 021 Explaining Variable Prefixes
${level} Beginner
${category} Internal Library: Collections
*** Test Cases ***
Lists Lists Lists
${list} = Create List a b c
@{also_list} = Set Variable a b c
Eat One List ${also_list}
Eat Many Values @{list}
Eat Many Values d e @{also_list}
${a} = Create List a
@{bc} = Set Variable b c
Log ABC ${a} @{bc}
*** Keywords ***
Eat One List
[Arguments] ${li}
Log Many @{li}
Log ${li}
Eat Many Values
[Arguments] @{li}
Log Many @{li}
Log ${li}
Log ABC
[Arguments] ${a} @{bc}
Log ${a}
Log ${bc}[0]
Log ${bc}[1]