Dela via


ThreadedWebTest Class

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

Inheritance Hierarchy

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

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

Syntax

'Declaration
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

The ThreadedWebTest type exposes the following members.

Constructors

  Name Description
Protected method ThreadedWebTest Initializes a new instance of the ThreadedWebTest class.

Top

Properties

  Name Description
Public property Context Gets or sets an object that contains context variables that are available to the Web performance test at run time. (Inherited from WebTest.)
Public property DataSources Gets the collection of data sources that are defined for the Web performance test. (Inherited from WebTest.)
Public property Guid Gets or sets a GUID that uniquely identifies each instance of a WebTest. (Inherited from WebTest.)
Public property InheritFromWebTest Gets the WebTest object for the parent Web performance test when this Web performance test is included in another Web performance test and inherits properties from the parent Web performance test. (Inherited from WebTest.)
Public property LastRequestOutcome (Inherited from WebTest.)
Public property LastResponse Gets the last response that was received for a top-level request in this Web performance test. (Inherited from WebTest.)
Public property Name Gets the name of the test case. (Inherited from WebTest.)
Public property Outcome Gets or sets the Pass or Fail outcome of the Web performance test. (Inherited from WebTest.)
Public property Password Gets and sets the password that is used for authentication. (Inherited from WebTest.)
Public property PreAuthenticate Gets or sets a value that indicates whether to pre-authenticate all requests in the Web performance test. (Inherited from WebTest.)
Public property Proxy Gets or sets a value that represents a proxy server for the Web performance test to use. (Inherited from WebTest.)
Public property RequestBodyCaptureLimit Gets or sets the limit, in bytes, that is used to capture request data. (Inherited from WebTest.)
Public property ResponseBodyCaptureLimit Gets or sets the limit, in bytes, that is used to capture response data. (Inherited from WebTest.)
Public property StopOnError Gets or sets the indication of whether the test should stop running when an error occurs. (Inherited from WebTest.)
Public property UserName Gets and sets the user name that is used for authentication. (Inherited from WebTest.)
Public property ValidationRuleReferences Gets the collection of references to Web performance test-level validation rules. (Inherited from WebTest.)
Public property WebProxy Gets or sets the Web proxy for this Web performance test to use. (Inherited from WebTest.)
Public property WebTestPluginReferences Gets the collection of references to Web performance test plug-ins. (Inherited from WebTest.)

Top

Methods

  Name Description
Public method AddCommentToResult Adds a comment to the Web performance test result that follows the most recently completed Web performance test request, transaction, or included Web performance test. (Inherited from WebTest.)
Public method AddDataSource(String, String, DataBindingAccessMethod, array<String[]) Adds a data source to the data collection that is contained by the Web performance test. (Inherited from WebTest.)
Public method AddDataSource(String, String, String, DataBindingAccessMethod, array<String[]) Adds a data source to the data collection that is contained by the Web performance test. (Inherited from WebTest.)
Public method AddDataSource(String, String, String, DataBindingAccessMethod, DataBindingSelectColumns, array<String[]) (Inherited from WebTest.)
Public method AddDataSourceBinding Defines a binding relationship and adds it to the data source binding collection for the Web performance test. (Inherited from WebTest.)
Public method BeginCondition (Inherited from WebTest.)
Public method BeginLoop (Inherited from WebTest.)
Public method BeginTransaction Starts a transaction timer by using the specified name. (Inherited from WebTest.)
Public method EndCondition (Inherited from WebTest.)
Public method EndLoop (Inherited from WebTest.)
Public method EndTransaction(String) Ends a transaction timer with the specified name. (Inherited from WebTest.)
Public method EndTransaction(String, Boolean) Ends the specified transaction. (Inherited from WebTest.)
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method ExecuteConditionalRule (Inherited from WebTest.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetDataTableRowCount (Inherited from WebTest.)
Public method GetEnumerator Gets an Enumerator that enumerates the items in the Web performance test. (Inherited from WebTest.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetRequestEnumerator Infrastructure. This method returns the next request to be submitted in a Web performance test for Web performance tests that extend the ThreadedWebTest class. (Overrides WebTest.GetRequestEnumerator().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IncludeWebTest(String) Calls a coded Web performance test from within a coded Web performance test. (Inherited from WebTest.)
Public method IncludeWebTest(WebTest) Calls a coded Web performance test from within a coded Web performance test. (Inherited from WebTest.)
Public method IncludeWebTest(String, Boolean) Calls a coded Web performance test from within a coded Web performance test. (Inherited from WebTest.)
Public method IncludeWebTest(WebTest, Boolean) Calls a coded Web performance test from within a coded Web performance test. (Inherited from WebTest.)
Public method InitializeDataBinding Adds data source and data binding information from attributes to the current instance. (Inherited from WebTest.)
Public method InternalSetOutcome (Inherited from WebTest.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method MoveDataTableCursor(String, String) Advances the cursor in the data table to the next record. (Inherited from WebTest.)
Public method MoveDataTableCursor(String, String, Int32) (Inherited from WebTest.)
Public method RegisterDataSourceInLoop (Inherited from WebTest.)
Public method ReloadDataTable (Inherited from WebTest.)
Public method Run When overridden in a derived class, runs the coded Web performance test of the user.
Public method Send Sends a WebTestRequest to be run by the Web performance test engine.
Public method Stop (Overrides WebTest.Stop().)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event PostPage (Inherited from WebTest.)
Public event PostRequest Occurs after each request that this Web performance test runs. (Inherited from WebTest.)
Public event PostTransaction (Inherited from WebTest.)
Public event PostWebTest Occurs after the Web performance test runs. (Inherited from WebTest.)
Public event PrePage (Inherited from WebTest.)
Public event PreRequest Occurs before each request this Web performance test runs. (Inherited from WebTest.)
Public event PreRequestDataBinding (Inherited from WebTest.)
Public event PreTransaction (Inherited from WebTest.)
Public event PreWebTest Occurs before the Web performance test runs. (Inherited from WebTest.)
Public event ValidateResponse Occurs when the response to a Web performance test request has been received and is ready to be validated. (Inherited from WebTest.)
Public event ValidateResponseOnPageComplete (Inherited from WebTest.)

Top

Remarks

This should always be the base class for all coded Web performance tests that are written in languages that do not support Visual C# iterator-like syntax. To write a Web performance test in Visual C#, see WebTest for an example. To run a test outside Visual Studio 2005 Team System, see Running Automated Tests from the Command Line 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 performance test called MyCodedWebTest that inherits from ThreadedWebTest. The second request posts the form information that is contained 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

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

Microsoft.VisualStudio.TestTools.WebTesting Namespace

Other Resources

Working with Web Tests Overview

Working with Web Tests

How to: Create a Coded Web Performance Test

How to: Edit an Existing Web Performance Test Using the Web Performance Test Editor