我有一个网站,我需要执行负载测试。我尝试了一个用户登录并点击然后注销。它工作正常,但现在我需要尝试50个用户。初始用户数为5,每20秒增加5,最大用户数为50。
会话管理所以我需要50个独特的登录,我有一组用户和相关的密码。我尝试进行一些搜索,但我无法弄清楚如何让测试与我拥有的用户一起运行。
这里有人有经验吗?
答案 0 :(得分:0)
考虑到您的问题,以下是一些有用的信息:https://msdn.microsoft.com/en-us/library/dn250793.aspx
这是关于在发布应用程序之前使用Visual Studio Ultimate中的负载测试来查找性能问题。
在Visual Studio Ultimate试用版中,虚拟用户数限制为250。
答案 1 :(得分:0)
如果您想要使用与测试数据中的用户帐户一样多的虚拟用户,则可以使用如下的Web测试插件:
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.ComponentModel;
namespace Plugins
{
[DisplayName("Lock Data Table Row to Virtual User Id")]
[Description("Makes each virtual user use the same data row as their user id. "
+ "Only works on first table of first data source. \r\n"
+ "LoadTest > Scenario > Percentage of New Users must be set to 0.")]
public class LockDataTableRowToVirtualUserIdWebTestPlugin : WebTestPlugin
{
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
int id = e.WebTest.Context.WebTestUserId;
// correct discrepancy (WebTests start at id 1, LoadTests start at id 0)
if (!e.WebTest.Context.ContainsKey("$LoadTestUserContext")) id -= 1;
int rows = e.WebTest.GetDataTableRowCount(e.WebTest.DataSources[0].Name, e.WebTest.DataSources[0].Tables[0].Name);
if (id > rows - 1) // not enough rows
throw new WebTestException("Not enough rows to provide all users with unique data; id=" + id + " rows=" + rows);
e.WebTest.MoveDataTableCursor(e.WebTest.DataSources[0].Name, e.WebTest.DataSources[0].Tables[0].Name, id);
}
}
}
要求“负载测试场景”属性中的“新用户百分比”设置设置为0,这会使每个虚拟用户的虚拟用户ID保持不变。否则,新的虚拟用户将获得超过数据行的新ID。
可以轻松地通过属性增强对命名DataSources / DataTables的处理。