WebTestPlugin.PreWebTest メソッド

更新 : 2007 年 11 月

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

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

構文

'宣言
Public Overridable Sub PreWebTest ( _
    sender As Object, _
    e As PreWebTestEventArgs _
)
'使用
Dim instance As WebTestPlugin
Dim sender As Object
Dim e As PreWebTestEventArgs

instance.PreWebTest(sender, e)
public virtual void PreWebTest(
    Object sender,
    PreWebTestEventArgs e
)
public:
virtual void PreWebTest(
    Object^ sender, 
    PreWebTestEventArgs^ e
)
public function PreWebTest(
    sender : Object, 
    e : PreWebTestEventArgs
)

パラメータ

解説

Web テストの実行の開始時に、コード実行のエントリ ポイントを提供します。

Web テストを実行する前に、PreWebTest メソッドを使用してコンテキストに乱数を追加する 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);
        }
        
    }
}

アクセス許可

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

参照

参照

WebTestPlugin クラス

WebTestPlugin メンバ

Microsoft.VisualStudio.TestTools.WebTesting 名前空間