首先,我首先回顾一下Testing SOAP/REST Web Services Using JMeter这家公司的网站已经证明对我很有价值。
在测试计划级别添加以下配置元素:
HTTP Request Defaults
Web Server Name: localhost
Port Number: 8080
Protocol: http
Content Encoding: utf8
在线程组,添加此配置元素:
HTTP Header Manager
Name: Content-Type
Value: application/json
现在,如果你实际创建的JSON数据你正在通过,我会通过RegEx对它进行参数化,然后可以在PUT请求中使用它。
CREATE HTTP Request
Method: POST
Path: /home/cmistest/app/documentservices/rest/nodes/create/12178
Use multipart/form-data for POST: enabled
Body Data:
{
"id": 0,
"name": "Star Lord",
"address": "123 Milky Way",
}
Regular Expression Extractor
Name: newWhateverId
Apply To: Main Sample Only
Field to check: Body
Reference Name: newWhateverId
Regular Expression: \,"Id":(.+?)\,
Template: $1$
Match No.: 1
Default Value: NONE
Regular Expression Extractor
Name: newWhateverBody
Apply To: Main Sample Only
Field to check: Body
Reference Name: newWhateverBody
Regular Expression: (?s)(^.*)
Template: $1$
Match No.: 1
Default Value: NONE
然后在PUT HTTP请求你可以通过在值:
PUT HTTP Request
Method: PUT
Path: /home/cmistest/app/documentservices/rest/nodes/upload/${newWhateverId}
Body Data:
{
${newWhateverBody}
}