共用方式為


TestStartingEventArgs 類別

包含 TestStarting 事件的引數。

繼承階層架構

System.Object
  System.EventArgs
    Microsoft.VisualStudio.TestTools.LoadTesting.TestStartingEventArgs

命名空間:  Microsoft.VisualStudio.TestTools.LoadTesting
組件:  Microsoft.VisualStudio.QualityTools.LoadTestFramework (在 Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll 中)

語法

'宣告
Public Class TestStartingEventArgs _
    Inherits EventArgs
public class TestStartingEventArgs : EventArgs
public ref class TestStartingEventArgs : public EventArgs
type TestStartingEventArgs =  
    class
        inherit EventArgs
    end
public class TestStartingEventArgs extends EventArgs

TestStartingEventArgs 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 IsInitializeTest 取得值,表示啟動的測試是否為負載測試情節之測試混合中指定的 InitializeTest。
公用屬性 IsTerminateTest 取得值,表示啟動的測試是否為負載測試情節之測試混合中指定的 TerminateTest。
公用屬性 ScenarioName 取得包含正在啟動中之測試的情節名稱。
公用屬性 TestContextProperties 取得包含資料的 IDictionary<TKey, TValue>,這些資料可以由載入測試中的個別測試加以使用。
公用屬性 TestIterationNumber 取得值,表示已經在特定代理程式上之載入測試中執行過的測試數目。
公用屬性 TestName 取得正在啟動中的測試名稱。
公用屬性 UserContext 取得 LoadTestUserContext,表示執行已啟動之測試的虛擬使用者。

回頁首

方法

  名稱 說明
公用方法 Equals 判斷指定的 Object 和目前的 Object 是否相等。 (繼承自 Object)。
受保護的方法 Finalize 允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。 (繼承自 Object)。
公用方法 GetHashCode 做為特定型別的雜湊函式。 (繼承自 Object)。
公用方法 GetType 取得目前執行個體的 Type。 (繼承自 Object)。
受保護的方法 MemberwiseClone 建立目前 Object 的淺層複本 (Shallow Copy)。 (繼承自 Object)。
公用方法 ToString 傳回表示目前物件的字串。 (繼承自 Object)。

回頁首

備註

TestStartingEventArgs 會建立用來將資料提供給這些測試 (包含於某個載入測試中) 的其他路徑。 TestStarting 事件的事件處理常式,可以包含將資料加入至這個載入測試中之個別測試的程式碼。 這個資料會被加入至 Web 測試中的 WebTestContext 或是單元測試中的 TestContext

範例

下列程式碼片段會示範如何使用 TestStartingEventArgs,將資料加入至載入測試中的起始測試反覆運算。 您必須將這個程式碼寫入至載入測試外掛程式中。

private void TestStarting(object source, TestStartingEventArgs testStartingEventArgs)
{
    testStartingEventArgs.TestContextProperties.Add("WebUser", GetNextWebUser());
}
private MyWebUser GetNextWebUser()
{
    /// Insert code here to read a user definition from some data source

    /// construct user object with data read from data source
    return new MyWebUser( ... );
}

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

Microsoft.VisualStudio.TestTools.LoadTesting 命名空間

其他資源

HOW TO:建立負載測試外掛程式

Understanding Load Tests