Test Data as Robot Variables
The main feature is that all Data read from the DataReaders are now also available as Robot Variables.
Example:
*** Settings ***
Library DataDriver encoding=utf8
Suite Setup Suite Start
Test Setup Start
Test Template DataDriver demo
Test Teardown End
Suite Teardown Suite End
*** Test Cases ***
Datadriver execution: ${number}
*** Keywords ***
Suite Start
Log ${DataDriver_DATA_LIST}
Log ${DataDriver_DATA_DICT}
Start
Log ${DataDriver_TEST_DATA}
DataDriver demo
[Arguments] ${username} ${password}
Log Many ${username} ${password}
End
Log Task Teardown ${idx}
Suite End
Log Suite Teardown ${idx}
Variables:
@{DataDriver_DATA_LIST}
A list as suite variable containing a robot dictionary for each test case that is selected for execution.
[
{
"test_case_name": "Right user empty pass",
"arguments": {
"${username}": "demo",
"${password}": "${EMPTY}"
},
"tags": [
"1"
],
"documentation": "This is a test case documentation of the first one."
},
{
"test_case_name": "Right user wrong pass",
"arguments": {
"${username}": "demo",
"${password}": "FooBar"
},
"tags": [
"2",
"3",
"foo"
],
"documentation": "This test case has the Tags 2,3 and foo"
},
{
"test_case_name": "Login with user '${EMPTY}' and password 'mode'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "mode"
},
"tags": [
"1",
"2",
"3",
"4"
],
"documentation": "This test case has a generated name based on template name."
},
{
"test_case_name": "Login with user '${EMPTY}' and password '${EMPTY}'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "${EMPTY}"
},
"tags": [
""
],
"documentation": ""
},
{
"test_case_name": "Login with user '${EMPTY}' and password 'FooBar'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "FooBar"
},
"tags": [
""
],
"documentation": ""
},
{
"test_case_name": "Login with user 'FooBar' and password 'mode'",
"arguments": {
"${username}": "FooBar",
"${password}": "mode"
},
"tags": [
"foo",
"1"
],
"documentation": ""
},
{
"test_case_name": "Login with user 'FooBar' and password '${EMPTY}'",
"arguments": {
"${username}": "FooBar",
"${password}": "${EMPTY}"
},
"tags": [
"foo"
],
"documentation": ""
},
{
"test_case_name": "Login with user 'FooBar' and password 'FooBar'",
"arguments": {
"${username}": "FooBar",
"${password}": "FooBar"
},
"tags": [
"foo",
"2"
],
"documentation": ""
}
]
This can be accessed as usual in Robot Framework®.
${DataDriver_DATA_LIST}[2][arguments][\${password}]
would result in mode
.
&{DataDriver_DATA_DICT}
A dictionary as suite variable that contains the same data as the list, with the test names as keys.
{
"Right user empty pass": {
"test_case_name": "Right user empty pass",
"arguments": {
"${username}": "demo",
"${password}": "${EMPTY}"
},
"tags": [
"1"
],
"documentation": "This is a test case documentation of the first one."
},
"Right user wrong pass": {
"test_case_name": "Right user wrong pass",
"arguments": {
"${username}": "demo",
"${password}": "FooBar"
},
"tags": [
"2",
"3",
"foo"
],
"documentation": "This test case has the Tags 2,3 and foo"
},
"Login with user '${EMPTY}' and password 'mode'": {
"test_case_name": "Login with user '${EMPTY}' and password 'mode'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "mode"
},
"tags": [
"1",
"2",
"3",
"4"
],
"documentation": "This test case has a generated name based on template name."
},
"Login with user '${EMPTY}' and password '${EMPTY}'": {
"test_case_name": "Login with user '${EMPTY}' and password '${EMPTY}'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "${EMPTY}"
},
"tags": [
""
],
"documentation": ""
},
"Login with user '${EMPTY}' and password 'FooBar'": {
"test_case_name": "Login with user '${EMPTY}' and password 'FooBar'",
"arguments": {
"${username}": "${EMPTY}",
"${password}": "FooBar"
},
"tags": [
""
],
"documentation": ""
},
"Login with user 'FooBar' and password 'mode'": {
"test_case_name": "Login with user 'FooBar' and password 'mode'",
"arguments": {
"${username}": "FooBar",
"${password}": "mode"
},
"tags": [
"foo",
"1"
],
"documentation": ""
},
"Login with user 'FooBar' and password '${EMPTY}'": {
"test_case_name": "Login with user 'FooBar' and password '${EMPTY}'",
"arguments": {
"${username}": "FooBar",
"${password}": "${EMPTY}"
},
"tags": [
"foo"
],
"documentation": ""
},
"Login with user 'FooBar' and password 'FooBar'": {
"test_case_name": "Login with user 'FooBar' and password 'FooBar'",
"arguments": {
"${username}": "FooBar",
"${password}": "FooBar"
},
"tags": [
"foo",
"2"
],
"documentation": ""
}
}
&{DataDriver_TEST_DATA}
A dictionary as test variable that contains the test data of the current test case.
This dictionary does also contain arguments that are not used in the Test Template
keyword.
This can be used in Test Setup and within a test case.
{
"test_case_name": "Right user wrong pass",
"arguments": {
"${username}": "demo",
"${password}": "FooBar"
},
"tags": [
"2",
"3",
"foo"
],
"documentation": "This test case has the Tags 2,3 and foo"
}