我想计算在不同功能中更新的累积时间。
测试用例文件
*** Settings ***
Suite Setup Pre_Execution_Steps
Suite Teardown Post_Execution_Steps
Library DateTime
Library Extended Selenium2Library
*** Test Cases ***
Test Case 1
Function A
资源文件
*** Settings ***
Library DateTime
Library ExtendedSelenium2Library
*** Keywords ***
Pre_Execution_Steps
Set Global Variable ${WAIT_TIME} 00:00:00.000
Function A:
${WAIT_TIME}= Add Time To Time ${WAIT_TIME} 00:00:02.001 result_format=timer
Log ${WAIT_TIME}
${WAIT_TIME}= Add Time To Time ${WAIT_TIME} 00:00:02.001 result_format=timer
Log ${WAIT_TIME}
Post_Execution_Steps
Log Wait time is ${WAIT_TIME}
当我执行测试用例时,全局变量$ {WAIT_TIME}值在函数A中更新。但$ {WAIT_TIME}值不会反映在Post_Execution_Steps中,尽管它是全局变量。它打印默认值00:00:00.000
任何输入/建议都会有所帮助
答案 0 :(得分:2)
我认为在Function A:
内,${WAIT_TIME}
一旦被设置为新值,就被视为本地。要查看对全局变量的更改,您需要在Set global variable
内调用Function A:
。