Asp mvc 5 集成测试 SpecsFor.Mvc

Asp mvc 5 integration tests SpecsFor.Mvc

我有问题 SpecsFor.Mvc

我正在尝试 运行 主机服务器:

public static SpecsForIntegrationHost _host;
public void SetupTestRun()
{
    string msBuild = ToolLocationHelper.GetPathToBuildToolsFile("msbuild.exe", "16.0");
    var config = new SpecsForMvcConfig();
    config.UseIISExpress()
    .With(Project.Named("WeatherApp.FrontEnd"))
    .UseMSBuildExecutableAt(msBuild);
    config.BuildRoutesUsing(r => RouteConfig.RegisterRoutes(r));
    config.UseBrowser(BrowserDriver.InternetExplorer);
    _host = new SpecsForIntegrationHost(config);
    _host.Start();
}

但是我收到了这个错误:

System.IO.FileLoadException: 'Could not load file or assembly 'System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' r one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

我该如何解决? 或者是否有其他类似的集成测试框架?

听起来您的规范项目引用了一个版本的 ASP.NET MVC,而您的实际 Web 应用程序引用了另一个版本。如果您使用的是 Visual Studio,您可以右键单击该解决方案并选择 "Manage NuGet Packages,",然后转到 "Consolidate" 选项卡。当您使用它时,确保这两个项目都是 运行 最新版本的 ASP.NET MVC 并没有什么坏处,并且您在两个项目上都有适当的绑定重定向以确保一切都转发到正确版本的 MVC。

希望对您有所帮助!