ThreadedWebTest 类
表示编码 Web 性能测试的基类,该测试在每个 Web 性能测试迭代中使用单个线程。
继承层次结构
System.Object
Microsoft.VisualStudio.TestTools.WebTesting.WebTest
Microsoft.VisualStudio.TestTools.WebTesting.ThreadedWebTest
命名空间: Microsoft.VisualStudio.TestTools.WebTesting
程序集: Microsoft.VisualStudio.QualityTools.WebTestFramework(在 Microsoft.VisualStudio.QualityTools.WebTestFramework.dll 中)
语法
声明
Public MustInherit Class ThreadedWebTest _
Inherits WebTest
public abstract class ThreadedWebTest : WebTest
public ref class ThreadedWebTest abstract : public WebTest
[<AbstractClass>]
type ThreadedWebTest =
class
inherit WebTest
end
public abstract class ThreadedWebTest extends WebTest
ThreadedWebTest 类型公开以下成员。
构造函数
名称 | 说明 | |
---|---|---|
ThreadedWebTest | 初始化 ThreadedWebTest 类的新实例。 |
页首
属性
名称 | 说明 | |
---|---|---|
Context | 获取或设置一个对象,该对象包含 Web 性能测试在运行时可用的上下文变量。 (继承自 WebTest。) | |
DataSources | 获取为此 Web 性能测试定义的数据源的集合。 (继承自 WebTest。) | |
Guid | 获取或设置 GUID,用于唯一标识 WebTest 中的每个实例。 (继承自 WebTest。) | |
InheritFromWebTest | 当此 Web 性能测试包含在另一 Web 性能测试中并继承父 Web 测试的属性时,获取父 Web 性能测试的 WebTest 对象。 (继承自 WebTest。) | |
LastRequestOutcome | (继承自 WebTest。) | |
LastResponse | 获取在该 Web 性能测试中为顶级请求接收的上一次响应。 (继承自 WebTest。) | |
Name | 获取测试用例的名称。 (继承自 WebTest。) | |
Outcome | 获取或设置 Web 性能测试求的“通过”或“未通过”结果。 (继承自 WebTest。) | |
Password | 获取和设置用于身份验证的密码。 (继承自 WebTest。) | |
PreAuthenticate | 获取或设置一个值,该值指示是否对 Web 性能测试内的所有请求进行预身份验证。 (继承自 WebTest。) | |
Proxy | 获取或设置一个值,该值表示 Web 性能测试要使用的代理服务器。 (继承自 WebTest。) | |
RequestBodyCaptureLimit | 获取或设置用于捕获请求数据的限制(以字节为单位)。 (继承自 WebTest。) | |
ResponseBodyCaptureLimit | 获取或设置用于捕获响应数据的限制(以字节为单位)。 (继承自 WebTest。) | |
StopOnError | 获取或设置是否应在出错时停止运行测试的指示。 (继承自 WebTest。) | |
UserName | 获取和设置用于身份验证的用户名。 (继承自 WebTest。) | |
ValidationRuleReferences | 获取对 Web 性能测试级验证规则的引用集合。 (继承自 WebTest。) | |
WebProxy | 获取或设置该 Web 性能测试要使用的 Web 代理。 (继承自 WebTest。) | |
WebTestPluginReferences | 获取对 Web 性能测试插件的引用集合。 (继承自 WebTest。) |
页首
方法
页首
事件
名称 | 说明 | |
---|---|---|
PostPage | (继承自 WebTest。) | |
PostRequest | 在该 Web 性能测试运行的每一个请求后发生。 (继承自 WebTest。) | |
PostTransaction | (继承自 WebTest。) | |
PostWebTest | 在 Web 性能测试运行之后发生。 (继承自 WebTest。) | |
PrePage | (继承自 WebTest。) | |
PreRequest | 在该 Web 性能测试运行的每一个请求前发生。 (继承自 WebTest。) | |
PreRequestDataBinding | (继承自 WebTest。) | |
PreTransaction | (继承自 WebTest。) | |
PreWebTest | 在 Web 性能测试运行之前发生。 (继承自 WebTest。) | |
ValidateResponse | 在对 Web 性能测试请求的响应已收到并且已准备好进行验证时发生。 (继承自 WebTest。) | |
ValidateResponseOnPageComplete | (继承自 WebTest。) |
页首
备注
这应该始终是使用不支持类似 Visual C# 迭代器的语法的语言编写的所有已编码 Web 性能测试的基类。 若要使用 Visual C# 编写 Web 性能测试,请参见 WebTest 以获得有关示例。 若要在 Visual Studio 2005 Team System 之外运行测试,请参见从命令行运行自动测试以获得更多信息。
必须继承该类;不能实例化该类。
对继承者的说明
当从 ThreadedWebTest 继承时,必须重写 Run。
示例
以下是一个从 ThreadedWebTest 继承的、名为 MyCodedWebTest 的编码 Web 性能测试。 第二个请求将三个控件中包含的窗体信息回发到服务器。
Option Strict Off
Option Explicit On
Imports Microsoft.VisualStudio.TestTools.WebTesting
Imports Microsoft.VisualStudio.TestTools.WebTesting.Rules
Imports System
Imports System.Collections.Generic
Namespace TestProject2
Public Class MyCodedWebTest
Inherits ThreadedWebTest
Public Sub New()
MyBase.New
Me.PreAuthenticate = true
Me.Proxy = "myproxy.com:80"
End Sub
Public Overrides Sub Run()
Dim request1 As WebTestRequest = New WebTestRequest _
("https://localhost/MyWebSite")
request1.ThinkTime = 1
Dim rule1 As ExtractHiddenFields = New ExtractHiddenFields
rule1.ContextParameterName = "1"
AddHandler request1.ExtractValues, AddressOf rule1.Extract
MyBase.Send(request1)
Dim request2 As WebTestRequest = New WebTestRequest _
("https://localhost/MyWebSite/Default.aspx")
request2.Method = "POST"
Dim request2Body As FormPostHttpBody = New FormPostHttpBody
request2Body.FormPostParameters.Add("__VIEWSTATE", "{{$HIDDEN1" + _
".__VIEWSTATE}}")
request2Body.FormPostParameters.Add("Button1", "Button")
request2Body.FormPostParameters.Add("TextBox1", "Hello text")
request2.Body = request2Body
Dim rule2 As ExtractHiddenFields = New ExtractHiddenFields
rule2.ContextParameterName = ""
AddHandler request2.ExtractValues, AddressOf rule2.Extract
MyBase.Send(request2)
End Sub
End Class
End Namespace
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
请参见
参考
Microsoft.VisualStudio.TestTools.WebTesting 命名空间