自動(dòng)化測(cè)試腳本通常都需要在不同環(huán)境中運(yùn)行,良好的測(cè)試環(huán)境參數(shù)化配置會(huì)使腳本的運(yùn)行具備較高的靈活性遍愿。
Robot Framework 框架支持一種「嵌套變量」的特性坞笙,我們可以利用該特性完成一種優(yōu)雅的環(huán)境參數(shù)化配置羞海。
*** Variables ***
# 環(huán)境管理
${environment} staging
# 域名管理
${host_api} ${host_api_${environment}}
${host_api_test} https://api-test.xxx.com
${host_api_staging} https://api-staging.xxx.com
${host_api-other} ${host_api-other_${environment}}
${host_api-other_test} https://api-other-test.xxx.com
${host_api-other_staging} https://api-other-staging.xxx.com