WebTest Class

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

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
'Usage
Dim instance As WebTest
[SerializableAttribute]
public abstract class WebTest : IEnumerable
[SerializableAttribute]
public ref class WebTest abstract : IEnumerable
public abstract class WebTest implements IEnumerable

Remarks

To create a coded Web 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 Command-Line Test Execution.

This class is serializable.

Notes to Inheritors:

When you inherit from WebTest, you must override GetRequestEnumerator.

Examples

The following Web 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;
        }
    }
}

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.TestTools.WebTesting.WebTest
    Microsoft.VisualStudio.TestTools.WebTesting.DeclarativeWebTest
    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

WebTest Members

Microsoft.VisualStudio.TestTools.WebTesting Namespace

Other Resources

Understanding Web Tests

Working with Web Tests

How to: Create a Coded Web Test