共用方式為


為何在使用模擬物件時不會拋出隨機錯誤

您可能會發現嘗試使用隨機錯誤和模擬時,Proxy 不會傳回隨機錯誤。 其中一個原因可能是 devproxyrc 組態中外掛程式的順序不正確。

Proxy 會按照在組態中定義的順序執行外掛程式。 在此情況下,模擬物件會在隨機錯誤之前執行,因此如果您有針對 URL 定義的模擬物件,請求永遠不會到達隨機錯誤外掛。

如果您要隨機錯誤和模擬,請將外掛程式的順序變更為:

{
  "plugins": [
    // [...] trimmed for brevity
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "genericRandomErrorPlugin"
    },
    {
      "name": "MockResponsePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "mocksPlugin"
    }
    // [...] trimmed for brevity
  ],
  // [...] trimmed for brevity
}

如此一來,會先處理隨機錯誤,而且任何未被 Proxy 隨機拒絕的請求,將與模擬進行比較。