When testing multiple interfaces, how to make the latter interface depend on the previous interface?
When testing multiple interfaces, how to make the latter interface depend on the previous interface and execute it sequentially
requests configuration as below
requests: [ { method: 'POST', path: '/api/login', setupRequest: (req, context) => { req.headers['Content-Type'] = 'application/json'; req.body = JSON.stringify({ username: 'demo' + Math.random(), password: '123' + Math.random() }); return req; }, onResponse: (status, body, context, headers) => { if (status == 200) { const cookie = headers['Set-Cookie'].split(';')[0]; context.token = cookie; loginSuccessNum++; console.log('1111'); } else { loginFailNum++; console.log('login请求失败'); } } }, { method: 'POST', path: '/api/checkToken', setupRequest: (req, context) => { console.log('22222'); return { ...req, headers: { cookie: context.token } }; }, onResponse: (status, body, context) => { if (status == 200) { tokenSuceessNum++; } else { console.log('checkToken请求失败', status); tokenFailNum++; } } } ];
Source: mcollina/autocannon