2012-06-08 206 views
1

就像this guy,我在創建MVC 4項目時沒有創建單元測試項目。現在我想回去添加一個。將單元測試項目添加到ASP.Net MVC 4項目

爲此,我創建了一個新的單元測試項目。爲什麼單位

Unit Test Generation Error: The following error was encountered while reading module 'My.Project': Could not resolve the type reference: [System.Web.Mvc, Version 3.0.0.0, Culture=neutral, PublicKeyToken={why doesn't MS support cut and paste??}]System.Web.Mvc.AllowAnonymousAttribute.

AllowAnonymousAttribute是新的MVC 4:

現在,我在一個私人的方法在我的控制器之一單擊鼠標右鍵,選擇創建單元測試,並得到一個彈出式對話框的認定儘管測試生成器試圖解決MVC 3程序集?

My.Project編譯並運行得很好,AllowAnonymousAttribute和all,顯然是尊重System.Web.Mvc,版本4.0.0.0。

UPDATE

MyMvc.csproj包含

<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> 
    <Private>True</Private> 
    <HintPath>..\packages\AspNetMvc.4.0.20126.16343\lib\net40\System.Web.Mvc.dll</HintPath> 
</Reference> 

在HintPath的DLL被證實爲版本4.0.0.0

MyMvc.Test.csproj包含

<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> 

回答

2

這不再是VS2012中的問題。

VS2012不再支持添加單元測試嚮導。手動添加的單元測試正常工作。

-1

下載resharper(有一個免費的30天的路徑)並按alt + enter。它會自動添加所需的內容。

+0

這並沒有解決問題。 –

相關問題