次の方法で共有


WebTestPlugin.PostWebTest メソッド

派生クラスでオーバーライドされた場合に、Web パフォーマンス テストの終了に関連付けられているイベントを処理するメソッドを表します。

名前空間:  Microsoft.VisualStudio.TestTools.WebTesting
アセンブリ:  Microsoft.VisualStudio.QualityTools.WebTestFramework (Microsoft.VisualStudio.QualityTools.WebTestFramework.dll 内)

構文

'宣言
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
)

パラメーター

解説

Web パフォーマンス テストの実行の末尾に、コード実行のエントリ ポイントを提供します。

Web パフォーマンス テストが実行される前にコンテキストにランダムな番号を追加する Web パフォーマンス テスト プラグインの例を次に示します。 同様に、PostWebTest をオーバーライドし、Web パフォーマンス テストの実行後にアクションを実行できます。 たとえば、Web パフォーマンス テストの完了にかかった時間と、Web パフォーマンス テスト中に発行された要求数をログ ファイルに書き込むことができます。

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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

WebTestPlugin クラス

Microsoft.VisualStudio.TestTools.WebTesting 名前空間