简体   繁体   English

使用Visual Studio 2017负载测试来测试具有不同请求主体的其余API

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

I have a rest API that creates things. 我有一个用于创建事物的rest API。 Let's say the end point is /create. 假设终点是/ create。 The request body determines what we want to create. 请求主体确定我们要创建的内容。 An example request body would be {"id":"1"}. 请求正文的示例为{“ 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. 如果我尝试创建具有相同ID的内容,则会收到错误消息,因此我想每次使用不同的ID。 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? 给出存储在文件或类似文件中的此类ID的列表,是否有可能创建一个负载测试,每次/ create被调用时都使用不同的ID?

Use a context parameter (CP) that has changing values and put it into the body, thus {"id":"{{theCp}}"} . 使用具有变化值的上下文参数(CP)并将其放入正文中,即{"id":"{{theCp}}"} This will insert the value of CP theCp into the body. 这会将CP theCp的值插入到主体中。

The CP might be from data driving the test. CP可能来自驱动测试的数据。 It might be created by some arithmetic (would probably need a plugin) on some values provided by Visual Studio. 它可能是由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. 请参阅Web测试结果的“上下文”选项卡以查看可用值的范围,但它们包括座席号,迭代号,用户ID等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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