Can someone explain me how to use default values for optional keyword arguments in connection with data-driven testcases?
As you can see in my example not all default values are used in some cases:
*** Test Cases ***
| testArgs | [Template] | doSomething
| | 111 : 222 : 333 : 444
| | xxx : 222 : 333 : 444 | xxx
| | 111 : xxx : 333 : 444 | | xxx
| | 111 : xxx : 333 : 444 | ${EMPTY} | xxx
| | None : xxx : 333 : 444 | ${None} | xxx
| | None : xxx : 333 : 444 | ${null} | xxx
| | 111 : 222 : xxx : 444 | | | xxx
*** Keywords ***
| doSomething
| | [Arguments] | ${expected} | ${arg1}=111 | ${arg2}=222 | ${arg3}=333 | ${arg4}=444
| | Log | exp: ${expected}
| | ${rc} | Set Variable | ${arg1} : ${arg2} : ${arg3} : ${arg4}
| | Log | arg: ${rc}
| | Run Keyword If | '${rc}' == '${expected}'
| | ... | Log | === equal ===
| | ... | ELSE
| | ... | Log | !!! diff !!!
| | Log | **************************
| | Should be equal | ${rc} | ${expected}
Result:
testArgs | FAIL |
Several failures occurred:
1) : xxx : 333 : 444 != 111 : xxx : 333 : 444
2) : xxx : 333 : 444 != 111 : xxx : 333 : 444
3) : : xxx : 444 != 111 : 222 : xxx : 444
I know that I can use named arguments to set specific keyword arguments. But this is only possible in keyword-driven testcases.
Regards, Tom
Call the specific keyword only with which argument you wanted to pass. eg:
*** Test Cases ***
TEST
MyKeyword a=1 c=3
*** Keywords ***
MyKeywords
[Arguments] ${a}=0 ${b}=2 ${c}=3
Here, I am not passing argument 'b'. By default it will take b=2