【发布时间】:2017-07-11 21:52:09
【问题描述】:
我的测试类中有一个静态对象,它通过负载测试插件填充,需要使用每个请求返回的数据进行更新。除了响应数据之外,我唯一需要的信息是发送请求时使用的原始 webtest 上下文中的 WebTestUserId。
我似乎可以通过验证规则来做到这一点:
ValidationClass: ValidationRule
{
public override void Validate(object sender, ValidationEventArgs e)
{
JObject responseBody = JObject.Parse(e.Response.BodyString);
int webTestUserId= ((TheTestClass)sender).Context.WebTestUserId;
// update some static field in the test class
}
}
但是,我确实看到了其他可能有效的选项,但在查找有关差异或推荐方法的文档时遇到了麻烦。我看到了事件处理程序:
WebTest.PostWebTest, WebTest.ValidateResponse, WebTest.ValidateResponseOnPageComplete 和 LoadTest.TestFinished(将在插件中使用)
我不能发布超过 2 个链接,但可以在 WebTest 类上找到两个未超链接的事件处理程序。
在什么情况下应该使用这些?
【问题讨论】:
标签: c# visual-studio visual-studio-2015 event-handling load-testing