共用方式為


WebTest.Outcome 屬性

更新:2007 年 11 月

取得或設定 Web 測試的「成功」或「失敗」結果。

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

語法

Public Property Outcome As Outcome

Dim instance As WebTest
Dim value As Outcome

value = instance.Outcome

instance.Outcome = value
public Outcome Outcome { get; set; }
public:
property Outcome Outcome {
    Outcome get ();
    void set (Outcome value);
}
public function get Outcome () : Outcome
public function set Outcome (value : Outcome)

屬性值

型別:Microsoft.VisualStudio.TestTools.WebTesting.Outcome

Web 測試的結果。

備註

設定 WebTest.Outcome 的主要原因是要忽略預期的失敗,因此儘管有預期的失敗,WebTest 還是會標示為「成功」。

因為 Web 測試執行階段引擎也會設定 WebTest 的 Outcome 屬性,所以 Outcome 屬性的最終值可能與您程式碼所設定的值不同。

如果您將 WebTest.Outcome 的值設定為 Fail,Web 測試執行階段引擎將不會覆寫該設定,而且 Web 測試完成時會標示為「失敗」。不過,如果您在 Web 測試當中 (在發出所有 Web 測試要求及叫用驗證規則之前) 將 WebTest.Outcome 設定為 Pass,只要在您將值設定為 Pass 之後發生錯誤,Web 測試執行階段引擎就會覆寫該值,並會將 WebTest.Outcome 設定為 Fail。

若要確保 WebTest.Outcome 的最終值為 Pass,請在 PostWebTest 事件處理常式中設定這個值。

使用權限

請參閱

參考

WebTest 類別

WebTest 成員

Microsoft.VisualStudio.TestTools.WebTesting 命名空間