SoapUI學習筆記

2021-08-20 02:29:40 字數 2911 閱讀 7072

properties定義不同維度(suite/testcase)下的測試變數

具體的型別為:project,testsuite,testcase,global。分別為專案級,測試集級,測試用例級和全域性。

以在左側custom properties/或者編輯視窗properties頁籤都可以新增變數

加入了引數之後,在測試步驟中可以用以下形式來呼叫引數。$

比如$   將獲取專案中定義的值

$   將獲取當前測試集中定義的值

$   將獲取當前測試用例中定義的值

通過屬性傳遞抽取乙個值 ,再通過datasink測試步驟或屬性寫入到乙個外部檔案

datagen,允許建立乙個計數器、隨機值等動態屬性

獲取測試集的屬性值

def username=testrunner.testcase.testsuite.getpropertyvalue("username")

testrunner.testcase.teststeps["properties"].getpropertyvalue("userid")

改變測試集屬性值

在script assertion中想要獲得屬性值的話可以用以下形式替代

def number = messageexchange.modelitem.testcase.teststeps["properties"].getpropertyvalue("userid

正規表示式或

.*(資料庫已經存在對應的資料|成功).*

獲取系統當前時間

cal = calendar.instance;

sysdate = cal.gettime().format('yyyy-mm-dd hh:mm:ss'); 

log.info(sysdate)

引數傳遞

data.status_token

data.[0].newsid

獲取隨機數

[email protected]

1. 依次執行專案下所有的測試用例

testrunner.bat spg2800-performance-soapui-project.xml –r

2. 依次執行testsuite下所有的測試用例

testrunner.bat spg2800-performance-soapui-project.xml -s spg2800_test -r 

3.執行指定的測試用例

testrunner.bat spg2800-performance-soapui-project.xml -c testcase_add_sbr -r

soapui 提供了乙個命令列工具 testrunner.bat 來執行乙個專案中的 testsuite, 可以在 /bin 下找到它, 它的使用非常簡單,只需要設定下面的幾個常用引數即可:

-s 指定要執行的 testsuite

-f 指定執行結果的輸出目錄

-j 生成 junit 風格的 report

-r 執行完成以後列印乙個簡單的 summary

下面這行命令就是執行 bookstore.xml 這個 soapui 專案中的 bookstoretestsuite, 把結果輸出到 c:\temp\reports 中。

testrunner.bat -sbookstoretestsuite -r -j c:\developerworks\soapui\bookstore.xml -f c:\temp\reports

有了 testrunner,把 soapui 的測試整合到 buildforge 中就很簡單了,只需要在 buildforge 的專案中新增乙個步驟

running soapui testrunner for [learningcloud]

directory: d:\program files (x86)\smartbear\soapui-pro-5.1.2\bin\.

"d:\program files (x86)\smartbear\soapui-pro-5.1.2\bin\"testrunner.bat -j -fc:\soapuilog -o -r"junit-style html report" -edefault -i -s "d:\02.soapui5.1.2 workspace\lproject-sit -new\soapui-project.xml"

指令碼斷言驗證響應時間

def  standardresponsetime= context.expand( '$' ) as long

def actualresponsetime = messageexchange.timetaken as long

log.info(actualresponsetime+' '+standardresponsetime)

assert  actualresponsetime <  standardresponsetime

指令碼步驟設定當前日期

cal = calendar.instance;

sysdate = cal.gettime().format('yyyy-mm-dd hh:mm:ss'); 

log.info(sysdate)

"properties"].setpropertyvalue('curtime', sysdate)

'curtime', sysdate)

testrunner.testcase.testsuite.setpropertyvalue('curtime', sysdate)

資料庫請求sql語句傳參select top 1 * from dbo.t_biz_plan  where planid = :planid

wsdl和wadl有哪些區別

wadl是用來新增備份的resource,wsdl是用來新增wsdl服務的

soapUI學習筆記 斷言的小使用

以下示例在soapui 4.5中進行。剛開始學soapui的使用,記錄下以免忘記 1.建立project 2.找到要測試的request,先請求一遍,可以請求成功。返回的結果中,有乙個字段值為x 3.選中request,右鍵 add to testcase,建立了乙個test case 4.然後對該...

soapUI學習筆記 斷言的小使用

以下示例在soapui 4.5中進行。剛開始學soapui的使用,記錄下以免忘記 1.建立project 2.找到要測試的request,先請求一遍,可以請求成功。返回的結果中,有乙個字段值為x 3.選中request,右鍵 add to testcase,建立了乙個test case 4.然後對該...

soapUI學習筆記 用例字段引數化

字段引數化的簡單操作 1.把request新增乙個testcase 增加testcase,下方會出現 2.案例中,請求引數只有乙個。先執行下請求,可以執行成功 保證介面是通的 3.新增引數。見圖中操作。properties命名隨意。這裡暫且就叫 properties 新增後的效果 新增引數,使用第一...