2012-06-08 124 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

这并没有解决问题。 –

相关问题