Reputation: 3160
I need to increase ${success_num}
test case variable in For Loop:
But it is always 0, even after I add 1 to it. It's like it's been reset after each iteration. How can I increase its value?
*** Test Cases ***
...
...
Set Test Variable ${success_num} ${0}
App For Port ${actual_app}
...
...
*** Keywords ***
App For Port [Arguments] ${app}
: FOR ${port_num} IN 1 2
\ ${PorF} ${message} Run Keyword And Ignore Error applicationcontrol.Launch application ${app} ${port_num}
\ Continue For Loop If '${PorF}'=='FALSE'
\ ${status} Run Keyword And Return Status Check launching status ${app} ${port_num}
\ Continue For Loop If '${status}'=='False'
\ Run Keyword If '${status}'=='True' Add Success
\ Exit For Loop
Add Success
${success_num} Set Variable ${success_num+1}
Upvotes: 5
Views: 11113
Reputation: 156
I recommend creating a Python function:
def Increment_Variable(p_num):
return int(p_num) + 1
and calling it as
${counter}= Increment Variable ${counter}
Upvotes: 0
Reputation: 6935
You don't have to call a keyword to increase success_num:
App For Port [Arguments] ${app}
: FOR ${port_num} IN 1 2
\ ${PorF} ${message} Run Keyword And Ignore Error applicationcontrol.Launch application ${app} ${port_num}
\ Continue For Loop If '${PorF}'=='FALSE'
\ ${status} Run Keyword And Return Status Check launching status ${app} ${port_num}
\ Continue For Loop If '${status}'=='False'
\ ${success_num} = Run Keyword If ${status} Set Variable ${success_num}+1 ELSE Set Variable ${success_num}
\ ${temp} = Run Keyword If ${status} Evaluate ${success_num}+1 ELSE Evaluate ${success_num}
\ Set Test Variable ${success_num} ${temp}
\ Exit For Loop
Upvotes: 3
Reputation: 3160
Change the keyword Add Success
to:
Add Success
${temp} Evaluate ${success_num} + 1
Set Test Variable ${success_num} ${temp}
Upvotes: 1