如何在单元测试期间停止开发服务器启动?

发布于 2024-08-13 20:58:09 字数 212 浏览 5 评论 0原文

我有一个 Visual Studio 2008 解决方案,其中包含大约 30 个项目。其中一些是 Web 服务/WCF 服务/ASP.NET MVC 应用程序。

当我运行所有单元测试(Ctr+R,A)时,它坚持为这些不同的项目启动所有开发服务器。这意味着运行测试需要太长时间,而且实际上,我的单​​元测试都不需要这些框架。

那么,如何阻止 Visual Studio 这样做呢?

I have a Visual Studio 2008 solution that contains around 30 projects. Some of these are web services / WCF services / ASP.NET MVC applications.

When I run all unit tests (Ctr+R, A) it insists on spinning up all the Development Servers for these various projects. This means that it takes far too long to run the tests and, actually, none of my unit tests require these frameworks.

So, how do I stop Visual Studio doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄司 2024-08-20 20:58:09

单击解决方案中的项目并打开属性窗口 (F4)。

调试时始终启动更改为false

Click on the projects in your solution and bring up the properties window (F4).

Change Always start when debugging to false.

雪若未夕 2024-08-20 20:58:09

如果您正在运行测试,而不是调试,那么“调试时始终启动”设置将不起作用。

相反,请查看您用于运行测试的测试设置。 (通过“测试”>“选择活动测试设置”查找您正在使用的设置。然后,您可以通过“测试”>“编辑测试设置”并选择活动测试设置来编辑测试设置)

我发现以下测试设置可以强制启动 ASP.NET 开发服务器,尽管还可以有更多!

  1. 非默认测试主机:在编辑测试设置窗口中,选择“主机”部分。主机类型应设置为“默认”,而不是“ASP.NET”
  2. 代码覆盖率:在编辑测试设置窗口中,选择“数据和诊断”部分。选择“代码覆盖率”并单击“配置”。开发服务器将为此处为 ASP.NET 代码覆盖率选择的每个服务启动。 (正常代码覆盖率由顶部有两个齿轮的空白页图标标识。ASP.NET 代码覆盖率由顶部有两个页面的地球图标标识。)从 ASP.NET 代码进行更改将覆盖率调整为正常代码覆盖率,取消选择 ASP.NET 代码覆盖率,然后选择“添加程序集...”。浏览到 Web 服务项目的 bin 文件夹并选择 Web 服务的 dll。

If you're running the tests, not debugging, then the "Always start when debugging" setting will have no effect.

Instead, have a look at the test settings that you're using to run the tests. (Find which settings you're using by going Test > Select Active Test Settings. You can then edit the test settings by going Test > Edit Test Settings and selecting your active test settings)

I have found the following test settings can force the ASP.NET development server to start up, although there could be more!

  1. Non-default test host: In the edit test settings window, choose the "Hosts" section. Host type should be set to "Default", not "ASP.NET"
  2. Code Coverage: In the edit test settings window, choose the "Data and Diagnostics" section. Select "Code Coverage" and click "Configure". The development server will start for each service that is selected here for ASP.NET Code Coverage. (Normal code coverage is identified by an icon of a blank page with two gears on top of it. ASP.NET code coverage is identified by an icon of a globe with two pages on top of it.) To change from ASP.NET code coverage to normal code coverage, deselect the ASP.NET code coverage, then choose "Add Assembly...". Browse to the bin folder of your web service project and choose the dll of the web service.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文