简体   繁体   中英

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. 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)?

In VS2010:

Team ExplorerProjectBuilds → In your " Build Definition " select Edit Build DefinitionProcess

Here you should configure:

  • 1.Required → Items to Build: select herer project and configuration to Build, ie Release or Debug in your case
  • 3.Advanced → Disable Tests: True/False

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:-

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM