二. Jmeter--关联
1. 首先建立一个线程组(Thread Group),为什么所有的请求都要加入线程组这个组件呢?不加不行吗?答案当然是不行的。因为jmeter的所有任务都必须由线程处理,所有任务都必须在线程组下面创建
2. 添加如下2个http request
POST http://xxxxxxxxxxx/agentservice/accesstoken HTTP/1.1
header
Content-Type: application/json
x-Mdata-Key: bc5bab92-e452-45cc-81cb-9d8c2cb80d6f
response:
{
"id": "FullSandboxSalesforce",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9._3Na6s",
"refreshToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9."
}
POST http://xxxxxxxxxxx/agentservice/clientHTTP/1.1
header
Authorization: Bearer <token>
x-userid: FullSandboxSalesforce
Content-Type: application/json
body
{
"email": "hilda0217600@mailinator.com",
"firstName": "hilda",
"lastName": "0217600",
"phone": "5550217600"
}
3.选中线程组(Thread Group),鼠标右键添加HTTP Request (POST), 添加HTTP Header Manager, 添加Regular Expression Extractor( 正则表达式取括号中的元素)
4. 添加第二个HTTP Request (POST), 添加HTTP Header Manager。引用变量${变量名}
5. 运行