WebTestPlugin.PostWebTest Method

When overridden in a derived class, represents the method that will handle the event associated with the end of a Web performance test.

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

Syntax

'Declaration
Public Overridable Sub PostWebTest ( _
    sender As Object, _
    e As PostWebTestEventArgs _
)
public virtual void PostWebTest(
    Object sender,
    PostWebTestEventArgs e
)
public:
virtual void PostWebTest(
    Object^ sender, 
    PostWebTestEventArgs^ e
)
abstract PostWebTest : 
        sender:Object * 
        e:PostWebTestEventArgs -> unit 
override PostWebTest : 
        sender:Object * 
        e:PostWebTestEventArgs -> unit 
public function PostWebTest(
    sender : Object, 
    e : PostWebTestEventArgs
)

Parameters

Remarks

This provides a code execution entry point at the end of a Web performance test run.

Examples

The following example shows a Web performance test plug-in that adds a random number to the context before the Web performance test is run. In the same way you can override PostWebTest and perform an action after the Web performance test has run. For example, you might want to write to a log file the time it takes to complete the Web performance test and the number of requests issued during the Web performance test.

using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Windows.Forms;

namespace WebTestPluginNamespace
{
    public class MyWebTestPlugin : WebTestPlugin
    {
        public static string NewRandomNumberString(int size)
        {
            byte[] buffer = new byte[size];
            // Seed using system time
            Random random = new Random(unchecked((int)DateTime.Now.Ticks));

            random.NextBytes(buffer);
            return BitConverter.ToInt32(buffer, 0).ToString();
        }

        public override void PreWebTest(object sender, PreWebTestEventArgs e)
        {
            e.WebTest.Context["RandNum"] = NewRandomNumberString(4);
        }
        
    }
}

.NET Framework Security

See Also

Reference

WebTestPlugin Class

Microsoft.VisualStudio.TestTools.WebTesting Namespace