1.說明
GraphQL是一種用於API調用的數據查詢語言
GraphQL接口概念及測試 大家可以了解一下
2.實戰
最近在做接口壓力測試,當前模擬的場景是通過openid獲取用戶token,用戶小程序中其他接口的調用
開發呢,就給我下圖,讓我調用
此時內心飄過一萬字......簡言之當開發真爽,苦逼的測試啊,好吧,也可能是我太渣
mutation{ |
看到這些內容,有點懵,這是啥格式
沒辦法,只能先用postman調用,確保接口ok,然后我們再在jmeter中進行調用
第一步:postman中調用
在postman中調用成功,得要了我們想要的結果
第二步:導出postman中請求信息
此時,可以獲取到我們后續將要使用到的入參
第三步:jmeter中調用
填入我們在postman中拿到的入參填入,進行調用,發現也得到了我們想要的結果
完美結束
3.GraphQL格式入參參數化
為了方便記錄,刪除了部分參數
原始入參: {"a":"a","query":"aa {\n w(\n input: {s: [{skuProperties: \"{\\\"size\\\":\\\"均碼\\\",\\\"color\\\":\\\"黑色\\\"}\"}], additionalServiceFee: {amount: 0}}\n ) {\n order {\n code\n orderCode\n __typename\n }\n __typename\n }\n}\n"} |
參數化: {"a":"a","query":"aa {\n w(\n input: {s: [{skuProperties: \"{\\\"size\\\":\\\"${size}\\\",\\\"color\\\":\\\"${color}\\\"}\"}], additionalServiceFee: {amount: 0}}\n ) {\n order {\n code\n orderCode\n __typename\n }\n __typename\n }\n}\n"} |
優化后: {"a":"a","query":"aa {\n w(\n input: {s: [{skuProperties: \"{\\\\\"size\\\\\":\\\\\"${size}\\\\\",\\\\\"color\\\\\":\\\\\"${color}\\\\\"}\"}],additionalServiceFee: {amount: 0}}\n ) {\n order {\n code\n orderCode\n __typename\n }\n __typename\n }\n}\n"}
|
參數化后執行,我們發現,請求的Body中內容格式同我們想要的不一致
優化后再執行,我們發現,請求的Body中內容格式同我們想要的一致了