Robotframework-RED-關(guān)鍵字封裝

Keywords的封裝有一般兩種方式,當(dāng)前測(cè)試集中封裝與單獨(dú)作為一個(gè)資源文件進(jìn)行封裝;下面分別舉個(gè)簡(jiǎn)單例子來說明下:

第一種方式:suite中封裝

先寫下簡(jiǎn)單的一點(diǎn)腳本:

*** Variables ***

${a} null

$ null

*** Test Cases ***

first-case

log ${a}+$

編寫與運(yùn)行截圖如下:

接下來在當(dāng)前suite中,編寫下Keywords并引用,腳本如下:

*** Variables ***

${a} null

$ null

*** Keywords ***

SUM

${a} Set Variable A

$ Set Variable B

Set Suite Variable ${a}

Set Suite Variable $

*** Test Cases ***

first-case

SUM

log ${a}+$

第二種方式:Keywords單獨(dú)在資源文件中

kw.robot腳本里面有個(gè)sum關(guān)鍵字,具體如下:

*** Keywords ***

SUM

${a} Set Variable A

$ Set Variable B

Set Suite Variable ${a}

Set Suite Variable $

1.kw.robot與demo-suite.robot在同一級(jí)別的目錄中,demo-suite.robot腳本如下:

*** Settings ***

Resource kw.robot

*** Variables ***

${a} null

$ null

*** Test Cases ***

first-case

SUM

log ${a}+$

2.kw.robot與demo-suite.robot在不在同一級(jí)別的目錄中,demo-suite.robot腳本如下:

*** Settings ***

Resource ../kw/kw.robot

*** Variables ***

${a} null

$ null

*** Test Cases ***

first-case

SUM

log ${a}+$

目錄結(jié)構(gòu)與腳本運(yùn)行,如下圖

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容