UPDATE:因此,只要我有像H ostType,AspNetDevelopmentServerHost,URLToTest
這樣的所有元標記,就會發生錯誤。所以,當我評論這些標籤時,我可以運行測試,但我需要讓這些標籤具有控制器連接到數據庫的連接字符串。 我在asp.net mvc的行動創造了一個基本的單元測試僅通過右擊並說Create unit tests..
。我是隻是想經營test.I正在此錯誤的基本單元 -在asp.net mvc中進行單元測試的問題?
The test adapter 'WebHostAdapter' threw an exception while running test 'IndexTest'. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://localhost:55767/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.
這是我的方法 -
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\Users\\Administrator\\Desktop\\MyWebsite\\Websites\\Customer1\\Customer1", "/")]
[UrlToTest("http://localhost:55767/Admin/Dashboard")]
public void IndexTest()
{
DashboardController target = new DashboardController(); // TODO: Initialize to an appropriate value
string id = string.Empty; // TODO: Initialize to an appropriate value
ActionResult expected = null; // TODO: Initialize to an appropriate value
ActionResult actual;
actual = target.Index(id);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
任何想法這裏的問題會是什麼?我試圖谷歌,但沒有得到一個很好的解決我的問題。我正在使用VS2010 Ultimate和asp.net mvc 2.0。
如果可能,您可以發佈Index操作方法和控制器構造函數(如果有)? – HitLikeAHammer 2010-10-19 17:05:08
我添加了示例代碼.. – Vishal 2010-10-20 14:45:20