简体   繁体   中英

Using Visual Studio 2017 Load Testing to test rest API with different request bodies

I have a rest API that creates things. Let's say the end point is /create. The request body determines what we want to create. An example request body would be {"id":"1"}. If I try to create something with the same id I will get an error so I would like to use a different id every time. Giving a list of these kind of ID's stored in a file or something similar, is it possible to create a load test that uses a different id every time /create is called?

Use a context parameter (CP) that has changing values and put it into the body, thus {"id":"{{theCp}}"} . This will insert the value of CP theCp into the body.

The CP might be from data driving the test. It might be created by some arithmetic (would probably need a plugin) on some values provided by Visual Studio. See the "Context" tab of the web test results to see the range of available values, but they include agent number, iteration number, user id and more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM