1. 程式人生 > >RF-template使用

RF-template使用

blog 進行 setting strong wid 設置方法 數據驅動 key ear

在測試案例中,可以使用template設置進行數據驅動的測試,template設置方法:

在設置項中填寫模板的關鍵字名稱,測試案例本身只能包含template關鍵字使用的數據;

技術分享

*** Settings ***
Resource 操作層.txt
Resource 流程層.txt

*** Test Cases ***
case1
[Setup] 初始化
[Template] 比較兩個數是否相等
1 2
3 3
5 4
[Teardown] 垃圾回收

技術分享

*** Keywords ***
初始化
log 測試前數據初始化完畢

垃圾回收
log 測試完成後垃圾回收完畢

執行超時
log 測試執行超時啦

比較兩個數是否相等
[Arguments] ${v1} ${v2}
should be equal ${v1} ${v2}

執行結果:


Starting test: Project2.套件層.case1
20170521 17:44:17.072 : INFO : 測試前數據初始化完畢
20170521 17:44:17.072 : INFO :
Argument types are:
<type ‘unicode‘>
<type ‘unicode‘>
20170521 17:44:17.088 : FAIL : 1 != 2
20170521 17:44:17.088 : INFO :
Argument types are:
<type ‘unicode‘>
<type ‘unicode‘>
20170521 17:44:17.088 : INFO :
Argument types are:
<type ‘unicode‘>
<type ‘unicode‘>
20170521 17:44:17.088 : FAIL : 5 != 4
20170521 17:44:17.088 : INFO : 測試完成後垃圾回收完畢
Ending test: Project2.套件層.case1

RF-template使用