VSTS 负载测试每个数据行运行一次
我有一个数据驱动的单元测试,它从访问数据库读取数据并执行数据库中的所有行。当我将其添加到负载测试并使用 5 个并发用户执行时,数据库中的所有记录都执行了 5 次。问题我这里面临的是,当数据库中有更多记录时,测试需要花费更多时间来执行。相反,有没有一种方法可以限制测试只执行一个数据行?
I have a datadriven unit test which reads from an access database and execute for all rows in the database.When I add this to a load test and execute with 5 concurrent users,all the records in the databse are executed 5 times.the problem I face here is when there are more records in the database the test takes more time for execution.instead is there a way to restrict a test to execute only one data row?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否试图在数据库中每行运行一次测试然后停止?如果是这样,您可能应该避免使用 Web 测试作为负载测试。
我认为你有两个选择,但我面前没有工作计算机来确认。
选项 1:像您已经完成的那样创建 Web 测试,包括将其连接到您可能已经拥有的访问数据库。然后将测试转换为编码的 Web 测试。并更改代码,以便它为数据源中的每个记录运行一次(换句话说,向编码的 webtest 添加一个外部循环)。
选项 2:编辑本地测试运行配置以运行测试 N 次。从主菜单转到测试/编辑测试运行配置,选择测试配置,从左侧窗格中选择 Web 测试,然后将固定运行计数更改为 5。我现在无法确认这一点,但我相信每次测试运行时它将前进到下一个记录,而不是停留在第一个记录上。
Are you trying to just run the test one time per row in the database and then stop? If so, you should probably avoid using your web test as a load test.
I think you have two options but I don't have my work computer in front of me to confirm.
Option 1: Create the web test like you've already done including wiring it up to the access database like you probably already have. Then convert the test to a coded web test. And change the code so that it runs once for each record in the datasource (in other words, add an outer loop to the coded webtest).
Option 2: Edit your local test run config to run the test N number of times. From the main menu go to Test/Edit Test Run Configurations, choose your test config, Select Web Test from the left pane, then change Fixed Run Count to 5. I can't confirm this right now but I believe each time the test runs it will advance to the next record as opposed to staying on the first.
我假设您只想在有一行数据可用时运行数据测试。
我将更改驱动测试的数据,以读取具有原子转换的存储过程,例如以下 SQL 代码:
这将在每次运行测试时为您提供一个唯一的数据行,从而允许在负载测试中使用测试。
您必须使用 SQL Express 而不是 access,因为我认为它不能很好地处理并发性(此处有待更正)。
如果您需要更多地控制负载测试期间发生的情况,请考虑 创建一个负载测试插件,它允许您从以下负载测试事件实现代码:
I assume you only want data tests to run when there is a row of data available.
I would change the data driving the test to read a stored procedure with an atomic transation such as this SQL code:
This will get you a unique datarow each time the test is run, allowing the test to be used in a load test.
You will have to use SQL Express instead of access as I don't think it can handle the concurrency so well (open to correction here).
If you need more control over what happens during the load test, consider creating a load test plugin that will allow you to implement code from the following load test events:
后来我弄清楚了负载测试中场景的测试迭代属性,以控制要为每个用户运行测试的次数。
在运行设置中,设置
使用测试迭代= true
测试迭代= xxx(您需要的迭代次数)
也可以在每次迭代之间暂停,
在负载测试的场景属性中,设置以下属性
1)Think Profile = On
2) 测试迭代之间的思考时间 = 1
later I figured out the test iterations property of the scenario in a load test to control the number of times you want to run a test for each user.
in the run settings,set
Use test iterations = true
test iterations = xxx(the number of iterations you need)
also to have pause between each iterations,
in the scenario properties of you load test,set the below properties
1)Think Profile = On
2)Think Time between test iterations = 1