我來教你postman怎么添加斷言 postman添加斷言方法。

postman怎么添加斷言?很多小伙伴不會操作,下面小編給大家帶來postman添加斷言方法,我們一起學習下吧 。
postman怎么添加斷言 postman添加斷言方法

我來教你postman怎么添加斷言 postman添加斷言方法。



打開上次保存的postman完成的訪問百度經驗的一個簡單的Get請求 。
9postman-測試GET請求

我來教你postman怎么添加斷言 postman添加斷言方法。


【我來教你postman怎么添加斷言 postman添加斷言方法?!?/strong>點擊Send,查看響應信息 。
這里就設置,檢查響應信息里面包含:百度經驗——實用生活指南
這幾個字 。
同時設置響應httpCode為200,斷言響應成功 。

我來教你postman怎么添加斷言 postman添加斷言方法。


點擊Url下方的Tests,這里設置斷言 。

我來教你postman怎么添加斷言 postman添加斷言方法。


點進來后這里是空的,你如果熟悉postman的函數,可以直接手動輸入,如果不熟悉,postman在右側已經提供了tests片段 。
點擊Learn more tests可以了解更多代碼片段 。

我來教你postman怎么添加斷言 postman添加斷言方法。


找到Response body:Contains string
響應body包含字符串 。
點擊 。

我來教你postman怎么添加斷言 postman添加斷言方法。


在Tests框內出現一段代碼片段,其他不用管,只需要將string_you_want_to_search字符串,替換為:百度經驗——實用生活指南
即可,而且代碼片段寫的很明白,從英文意思就可以了解該如何設置 。

我來教你postman怎么添加斷言 postman添加斷言方法。



我來教你postman怎么添加斷言 postman添加斷言方法。


找到代碼片段 。Status code:code is 200.
點擊 。

我來教你postman怎么添加斷言 postman添加斷言方法。


生成斷言httpCode為200的代碼片段 。

我來教你postman怎么添加斷言 postman添加斷言方法。


Ctrl s保存一下請求的設置 。
然后點擊Send發送請求,查看響應信息 。
響應中查看Tests Results 。
設置的檢查全部成功 。

我來教你postman怎么添加斷言 postman添加斷言方法。


以上就是postman添加斷言方法,更多精彩教程盡在本站!

    推薦閱讀