简体   繁体   English

如何在TFS下的Release模式下禁用单元测试

[英]How to disable unit tests in Release mode under TFS

I want to setup the TFS to build both Debug and Release versions of my solutions but only run the unit tests when in Debug mode. 我想设置TFS来构建我的解决方案的Debug和Release版本,但只在Debug模式下运行单元测试。 I've tried disabling the builds for the test projects in my solutions' Configuration Properties, but to no avail. 我尝试在我的解决方案的配置属性中禁用测试项目的构建,但无济于事。 And what's annoying is that the tests will always fail in Release mode because it can't seem to find the files even though they exist... 令人讨厌的是,测试将始终在发布模式下失败,因为即使它们存在,它似乎也无法找到文件...

So anyone know how to get TFS to run the unit tests only in Debug mode (but still build both Debug and Release modes)? 所以任何人都知道如何让TFS仅在调试模式下运行单元测试(但仍构建调试和发布模式)?

In VS2010: 在VS2010中:

Team ExplorerProjectBuilds → In your " Build Definition " select Edit Build DefinitionProcess Team ExplorerProjectBuilds →在“ 构建定义 ”中选择“ Edit Build Definition →“ Process

Here you should configure: 在这里你应该配置:

  • 1.Required → Items to Build: select herer project and configuration to Build, ie Release or Debug in your case 1.Required→要构建的项目:选择herer项目和配置进行构建,即在您的情况下发布或调试
  • 3.Advanced → Disable Tests: True/False 3.Advanced→禁用测试:是/否

I've finally found out how to do it. 我终于找到了如何做到这一点。 In the TFS build definition file (.proj), under the section for listing out the test list/DLLs, just add a $(Configuration) condition to each item as follows:- 在TFS构建定义文件(.proj)中,在列出测试列表/ DLL的部分下,只需为每个项添加$(配置)条件,如下所示: -

<ItemGroup>
    <MetaDataFile Condition="'$(Configuration)'=='Debug'" Include="$(BuildProjectFolderPath)/SubFolders/MyTestListFile.vsmdi">
      <TestList>My Test List Name</TestList>
    </MetaDataFile>

    <TestContainer Condition="'$(Configuration)'=='Debug'" Include="$(OutDir)\MyTests.dll" />
</ItemGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VS2010中的单元测试(发布模式下的解决方案) - Unit tests in VS2010 (solution in release mode) 如何强制我的TFS 2010 Build构建要在调试或发布模式下构建的解决方案中的所有项目? - How do I force my TFS 2010 Build to build all projects in the solution to be built in Debug or Release Mode? 如何在TFS 2010的Build-Deploy-Test构建中运行许多单元测试? - How do I run many unit tests in Build-Deploy-Test build in TFS 2010? 在调试器下运行Boost单元测试 - Run boost unit tests under debugger MSTest:以64位模式运行单元测试 - MSTest: running unit tests in 64 bit mode 如何在发布模式下调试? - How to debug in release mode? 在调试模式下运行单元测试时,如何调用多个启动项目 - How do I invoke Multiple Startup Projects when running a unit tests in Debug Mode 在VS2010下的OpenCV 2.4.2中,发布模式下的运行时错误? - Runtime error in Release mode in OpenCV 2.4.2 under VS2010? 具有MSTests单元测试以及TFS2008和MsBuild的VS2010解决方案-无法运行单元测试 - VS2010 solution with MSTests unit tests and TFS2008 and MsBuild - fails to run unit test 如何使用TFS 2010中的构建设置测试 - How to setup tests using builds in TFS 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM