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 | |
---|---|---|
WebTest | Initializes a new instance of a class that is derived from WebTest class. |
Top
Properties
Name | Description | |
---|---|---|
Context | Gets or sets an object that contains context variables that are available to the Web performance test at run time. | |
DataSources | Gets the collection of data sources that are defined for the Web performance test. | |
Guid | Gets or sets a GUID that uniquely identifies each instance of a WebTest. | |
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. | |
LastRequestOutcome | ||
LastResponse | Gets the last response that was received for a top-level request in this Web performance test. | |
Name | Gets the name of the test case. | |
Outcome | Gets or sets the Pass or Fail outcome of the Web performance test. | |
Password | Gets and sets the password that is used for authentication. | |
PreAuthenticate | Gets or sets a value that indicates whether to pre-authenticate all requests in the Web performance test. | |
Proxy | Gets or sets a value that represents a proxy server for the Web performance test to use. | |
RequestBodyCaptureLimit | Gets or sets the limit, in bytes, that is used to capture request data. | |
ResponseBodyCaptureLimit | Gets or sets the limit, in bytes, that is used to capture response data. | |
StopOnError | Gets or sets the indication of whether the test should stop running when an error occurs. | |
UserName | Gets and sets the user name that is used for authentication. | |
ValidationRuleReferences | Gets the collection of references to Web performance test-level validation rules. | |
WebProxy | Gets or sets the Web proxy for this Web performance test to use. | |
WebTestPluginReferences | Gets the collection of references to Web performance test plug-ins. |
Top
Methods
Name | Description | |
---|---|---|
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. | |
AddDataSource(String, String, DataBindingAccessMethod, array<String[]) | Adds a data source to the data collection that is contained by the Web performance test. | |
AddDataSource(String, String, String, DataBindingAccessMethod, array<String[]) | Adds a data source to the data collection that is contained by the Web performance test. | |
AddDataSource(String, String, String, DataBindingAccessMethod, DataBindingSelectColumns, array<String[]) | ||
AddDataSourceBinding | Defines a binding relationship and adds it to the data source binding collection for the Web performance test. | |
BeginCondition | ||
BeginLoop | ||
BeginTransaction | Starts a transaction timer by using the specified name. | |
EndCondition | ||
EndLoop | ||
EndTransaction(String) | Ends a transaction timer with the specified name. | |
EndTransaction(String, Boolean) | Ends the specified transaction. | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
ExecuteConditionalRule | ||
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetDataTableRowCount | ||
GetEnumerator | Gets an Enumerator that enumerates the items in the Web performance test. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetRequestEnumerator | When overridden in a derived class, returns an IEnumerator<T> interface that supports a simple iteration over a generic collection of WebTestRequest. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IncludeWebTest(String) | Calls a coded Web performance test from within a coded Web performance test. | |
IncludeWebTest(WebTest) | Calls a coded Web performance test from within a coded Web performance test. | |
IncludeWebTest(String, Boolean) | Calls a coded Web performance test from within a coded Web performance test. | |
IncludeWebTest(WebTest, Boolean) | Calls a coded Web performance test from within a coded Web performance test. | |
InitializeDataBinding | Adds data source and data binding information from attributes to the current instance. | |
InternalSetOutcome | ||
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MoveDataTableCursor(String, String) | Advances the cursor in the data table to the next record. | |
MoveDataTableCursor(String, String, Int32) | ||
RegisterDataSourceInLoop | ||
ReloadDataTable | ||
Stop | Stops the current Web performance test. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
PostPage | ||
PostRequest | Occurs after each request that this Web performance test runs. | |
PostTransaction | ||
PostWebTest | Occurs after the Web performance test runs. | |
PrePage | ||
PreRequest | Occurs before each request this Web performance test runs. | |
PreRequestDataBinding | ||
PreTransaction | ||
PreWebTest | Occurs before the Web performance test runs. | |
ValidateResponse | Occurs when the response to a Web performance test request has been received and is ready to be validated. | |
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