2015-04-22 34 views
1

當試圖運行單元測試我得到這個錯誤:指定的URL()不對應於有效的目錄。

Test Name: GetMethodTest Test FullName: Quanser.Codex.App.Web.Repository.UnitTests.DocumentsControllerTests.GetMethodTest Test Source: c:\Dev\Engineering\Mobile Apps\Software\Codex\trunk\Web\Repository\UnitTests.Repository\DocumentsControllerTests.cs : line 34 Test Outcome: Failed Test Duration: 0:00:00

Result Message: The URL specified (' http://localhost:53364/ ') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application.

這是我的測試案例:

[TestMethod()] 
    [HostType("ASP.NET")] 
    [UrlToTest("http://localhost:53364/")] 
    public void GetMethodTest() 
    { 
     // ... 
    } 

我知道有什麼不對的這條線:

[UrlToTest("http://localhost:53364/")] 

我應該將這個Url放入這個屬性中?

注:我需要使用這些屬性用於測試REST API

感謝

+1

也許這是一個許可問題,如[本文] [1]中所述。 [1]:http://stackoverflow.com/questions/9065937/asp-net-unit-testing-windows7-iis7 – cDima

回答

1

這些屬性對於測試ASP.NET Web窗體項目。如果您只需要測試WebAPI控制器,那麼您應該能夠刪除它們,例如

[TestMethod()] 
public void GetMethodTest() 
{ 
    // ... 
} 
相關問題