ThreadedWebTest Class

Represents a base class for a coded Web test that uses a single thread per Web test iteration.

Namespace:  Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

Syntax

'Declaration
Public MustInherit Class ThreadedWebTest _
    Inherits WebTest
'Usage
Dim instance As ThreadedWebTest
public abstract class ThreadedWebTest : WebTest
public ref class ThreadedWebTest abstract : public WebTest
public abstract class ThreadedWebTest extends WebTest

Remarks

This should always be the base class for all coded Web tests written in languages that do not support Visual C# iterator-like syntax. To write a Web test in Visual C#, see WebTest for an example. To run a test outside Visual Studio 2005 Team System, see Command-Line Test Execution for more information.

This class must be inherited; it cannot be instantiated.

Notes to Inheritors:

When you inherit from ThreadedWebTest, you must override Run.

Examples

The following is a coded Web test called MyCodedWebTest that inherits from ThreadedWebTest. The second request posts form information that is contained within in three controls back to the server.

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

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.TestTools.WebTesting.WebTest
    Microsoft.VisualStudio.TestTools.WebTesting.ThreadedWebTest

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ThreadedWebTest Members

Microsoft.VisualStudio.TestTools.WebTesting Namespace

Other Resources

Understanding Web Tests

Working with Web Tests

How to: Create a Coded Web Test

How to: Edit an Existing Web Test