天天看點

Postman的進階用法—Runner的使用​

作者:松勤小豬

1

1.首先在postman建立要批量運作的接口檔案夾,建立一個接口,并設定好全局變量。

Postman的進階用法—Runner的使用​

2

2.然後在Test裡面設定好要斷言的方法

如:tests["Status code is 200"] = responseCode.code === 200;tests["Response time is less than 10000ms"] = responseTime < 10000;console.log(responseTime);

3

3.儲存後,點選Runner,選擇剛才建立的檔案夾,設定好疊代和測試環境

Postman的進階用法—Runner的使用​

4

4.步驟一中設定的接口全局變量是flightdate,我們在每次疊代中給這個變量指派,就需要用到csv或者json檔案,如我用的json檔案。

4.步驟一中設定的接口全局變量是flightdate,我們在每次疊代中給這個變量指派,就需要用到csv或者json檔案,如我用的json檔案。

17

[

{

"flightDate": "2017-02-09"

},

{

"flightDate": "2017-02-10"

},

{

"flightDate": "2017-02-11"

},

{

"flightDate": "2017-02-12"

},

{

"flightDate": "2017-02-13"

}

注意:json的key一定要與變量名一緻,json的格式是數組形式

5

5.在Runner中選擇該json檔案,點選預覽效果:

Postman的進階用法—Runner的使用​

6

6.配置好後,點選start test,即可看到運作結果。

Postman的進階用法—Runner的使用​

繼續閱讀