Condividi tramite


Metodo WebTestPlugin.PostWebTest

Se sottoposto a override in una classe derivata, rappresenta il metodo che gestirà l'evento associato alla fine del test delle prestazioni Web.

Spazio dei nomi:  Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

Sintassi

'Dichiarazione
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
)

Parametri

Note

Fornisce un punto di ingresso di esecuzione del codice al termine di un test delle prestazioni Web.

Esempi

Nell'esempio seguente viene illustrato un plug-in di test delle prestazioni Web che aggiunge un numero casuale al contesto prima dell'esecuzione del test delle prestazioni Web. Analogamente è possibile eseguire l'override di PostWebTest ed eseguire un'azione dopo l'esecuzione del test delle prestazioni Web. È ad esempio possibile scrivere in un file di log il tempo necessario per completare il test delle prestazioni Web e il numero di richieste emesse durante tale 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);
        }
        
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

WebTestPlugin Classe

Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting