Share via


WebTest Class

Base class for all Web performance tests. Coded Web performance tests that are written in C# derive directly from this class.

Inheritance Hierarchy

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

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

Syntax

'Declaration
<SerializableAttribute> _
Public MustInherit Class WebTest _
    Implements IEnumerable
[SerializableAttribute]
public abstract class WebTest : IEnumerable
[SerializableAttribute]
public ref class WebTest abstract : IEnumerable
[<AbstractClass>]
[<SerializableAttribute>]
type WebTest =  
    class
        interface IEnumerable
    end
public abstract class WebTest implements IEnumerable

The WebTest type exposes the following members.

Constructors

  Name Description
Protected method WebTest Initializes a new instance of a class that is derived from WebTest 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.
Public property DataSources Gets the collection of data sources that are defined for the Web performance test.
Public property Guid Gets or sets a GUID that uniquely identifies each instance of a 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.
Public property LastRequestOutcome
Public property LastResponse Gets the last response that was received for a top-level request in this Web performance test.
Public property Name Gets the name of the test case.
Public property Outcome Gets or sets the Pass or Fail outcome of the Web performance test.
Public property Password Gets and sets the password that is used for authentication.
Public property PreAuthenticate Gets or sets a value that indicates whether to pre-authenticate all requests in the Web performance test.
Public property Proxy Gets or sets a value that represents a proxy server for the Web performance test to use.
Public property RequestBodyCaptureLimit Gets or sets the limit, in bytes, that is used to capture request data.
Public property ResponseBodyCaptureLimit Gets or sets the limit, in bytes, that is used to capture response data.
Public property StopOnError Gets or sets the indication of whether the test should stop running when an error occurs.
Public property UserName Gets and sets the user name that is used for authentication.
Public property ValidationRuleReferences Gets the collection of references to Web performance test-level validation rules.
Public property WebProxy Gets or sets the Web proxy for this Web performance test to use.
Public property WebTestPluginReferences Gets the collection of references to Web performance test plug-ins.

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.
Public method AddDataSource(String, String, DataBindingAccessMethod, array<String[]) Adds a data source to the data collection that is contained by the Web performance test.
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.
Public method AddDataSource(String, String, String, DataBindingAccessMethod, DataBindingSelectColumns, array<String[])
Public method AddDataSourceBinding Defines a binding relationship and adds it to the data source binding collection for the Web performance test.
Public method BeginCondition
Public method BeginLoop
Public method BeginTransaction Starts a transaction timer by using the specified name.
Public method EndCondition
Public method EndLoop
Public method EndTransaction(String) Ends a transaction timer with the specified name.
Public method EndTransaction(String, Boolean) Ends the specified transaction.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method ExecuteConditionalRule
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
Public method GetEnumerator Gets an Enumerator that enumerates the items in the Web performance test.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetRequestEnumerator When overridden in a derived class, returns an IEnumerator<T> interface that supports a simple iteration over a generic collection of WebTestRequest.
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.
Public method IncludeWebTest(WebTest) Calls a coded Web performance test from within a coded Web performance test.
Public method IncludeWebTest(String, Boolean) Calls a coded Web performance test from within a coded Web performance test.
Public method IncludeWebTest(WebTest, Boolean) Calls a coded Web performance test from within a coded Web performance test.
Public method InitializeDataBinding Adds data source and data binding information from attributes to the current instance.
Public method InternalSetOutcome
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.
Public method MoveDataTableCursor(String, String, Int32)
Public method RegisterDataSourceInLoop
Public method ReloadDataTable
Public method Stop Stops the current Web performance test.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

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

Top

Remarks

To create a coded Web performance test in Visual Basic 2005, see ThreadedWebTest.

For a list of initial property values for an instance of WebTest class, see the WebTest constructor.

For more information about how to run a test outside Visual Studio 2005 Team System, see Running Automated Tests from the Command Line.

This class is serializable.

Notes to Inheritors

When you inherit from WebTest, you must override GetRequestEnumerator.

Examples

The following Web performance test extracts values that represent the status of check boxes and adds the values to the context.

namespace TestProject1
{
    using System;
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.WebTesting;
    using ClassLibrary2;

    public class MyWebTest : WebTest
    {
        public MyWebTest()
        {
            this.PreAuthenticate = true;
        }

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest request1 = new WebTestRequest("https://localhost/ts");
            ExtractCheckBoxes rule1 = new ExtractCheckBoxes();
            rule1.FindCheckedBoxes = true;
            rule1.ContextParameterName = "CheckedBoxes";
            request1.ExtractValues += new EventHandler
                <ExtractionEventArgs>(rule1.Extract);
            ExtractCheckBoxes rule2 = new ExtractCheckBoxes();
            rule2.FindCheckedBoxes = false;
            rule2.ContextParameterName = "";
            request1.ExtractValues += new EventHandler
                <ExtractionEventArgs>(rule2.Extract);
            yield return request1;
        }
    }
}

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