尝试测试 SpecsFor.Mvc,不幸的是,当我尝试运行测试时,我遇到了这个奇怪的构建错误。
在我自己的项目和 SpecsFor 最新源中运行时,我得到“构建失败”。来自 IISTestRunnerAction 类的 ApplicationException。以下来自日志文件,但超出了我的理解。
使用 Visual Studio 2012 Pro 和 IIS Express 8.0
以下来自日志文件:
使用程序集“C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.Tasks.dll”中的“VSMSDeploy”任务。任务“VSMSDeploy”打包/发布任务 Microsoft.Web.Publishing.Tasks.VSMSDeploy 加载程序集 Microsoft.Web.Deployment,Version=9.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35 打包/发布任务 Microsoft.Web.Publishing.Tasks。 VSMSDeploy 加载程序集 Microsoft.Web.Delegation,Version=7.1.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35 从源启动 Web 部署任务:manifest(C:\Users\Chris\Desktop\SpecsFor-master\SpecsFor.Mvc.Demo\ obj\Test\Package\SpecsFor.Mvc.Demo.SourceManifest.xml)到目的地:包(C:\Users\Chris\Desktop\SpecsFor-master\SpecsFor.Mvc.Demo\obj\Test\Package\SpecsFor.Mvc.演示.zip)。C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4007,5):错误:Web 部署任务失败。(“Microsoft.Web.Deployment.DeploymentManager”的类型初始化程序引发异常。)包失败。完成执行任务“VSMSDeploy”——失败。
更新
这是 AssemblyStartup
[SetUpFixture]
public class AssemblyStartup
{
private SpecsForIntegrationHost _host;
[SetUp]
public void SetupTestRun()
{
var config = new SpecsForMvcConfig();
//SpecsFor.Mvc can spin up an instance of IIS Express to host your app
//while the specs are executing.
config.UseIISExpress()
//To do that, it needs to know the name of the project to test...
.With(Project.Named("SpecsForTesting"))
//And optionally, it can apply Web.config transformations if you want
//it to.
.ApplyWebConfigTransformForConfig("Debug");
//In order to leverage the strongly-typed helpers in SpecsFor.Mvc,
//you need to tell it about your routes. Here we are just calling
//the infrastructure class from our MVC app that builds the RouteTable.
config.BuildRoutesUsing(r => SpecsForTesting.RouteConfig.RegisterRoutes(r));
//SpecsFor.Mvc can use either Internet Explorer or Firefox. Support
//for Chrome is planned for a future release.
config.UseBrowser(BrowserDriver.Chrome);
//Does your application send E-mails? Well, SpecsFor.Mvc can intercept
//those while your specifications are executing, enabling you to write
//tests against the contents of sent messages.
config.InterceptEmailMessagesOnPort(13565);
//The host takes our configuration and performs all the magic. We
//need to keep a reference to it so we can shut it down after all
//the specifications have executed.
_host = new SpecsForIntegrationHost(config);
_host.Start();
}
//The TearDown method will be called once all the specs have executed.
//All we need to do is stop the integration host, and it will take
//care of shutting down the browser, IIS Express, etc.
[TearDown]
public void TearDownTestRun()
{
_host.Shutdown();
}
}