Answered Unit Test cases are not being executed in the TFS 2010 Ms Build

  • Monday, March 12, 2012 6:01 AM
     
     

    Hi,

    We have migrated from TFS 2008 to TFS 2010.

    After this we are not able to get our unit test cases executed in the during build.

    Here are the steps we follow to ensure unit testing in build project.

    1. Enable Run Test

    2. Set Test container.

    <

    TestContainer Include="$(OutDir)\test1.dll" />

    <

    TestContainer Include="$(OutDir)\test2.dll" />

    After some investeigation, we narrowed down to a problem in build.Log

    Task "TestToolsTask" skipped, due to false condition; ( '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' )

    There are two parameters defined in Microsoft.TeamFoundation.Build.Targets 1)V8TestToolsTask 2) IsDesktoBuild. These bool parameters are being overridden during build execution and because of this the “TestToolsTask” is being skipped.Hard coding the above mentioned parameters in MSBuild. Targets also didn’t solve the problem . Please lets us know where could be the problem.


All Replies

  • Wednesday, March 14, 2012 3:35 AM
    Moderator
     
      Has Code

    Hi,

    While I investigate this issue, it turns out to be a known issue in TFS 2008. TFS 2010 has fixed it, as you may be using the TFS 2008 build project, in which case the issue exists.

    There's a workaround for this issue, copy the CoreTestConfiguration target from Microsoft.Build.Targets and add the <CreateItem> to the top:

     <Target Name="CoreTestConfiguration"
         DependsOnTargets="$(CoreTestConfigurationDependsOn)"
         Outputs="@(TestOutputs)">
    
        <!-- Start workaround for TestContainer for TeamBuild + Desktop Builds -->
        <Message Text="Using unit tests from: $(BinariesRoot)\$(Configuration)\*.Tests.dll" Condition=" '$(IsDesktopBuild)'=='true' " />
    
        <CreateItem Include="$(BinariesRoot)\$(Configuration)\*.Tests.dll">
         <Output TaskParameter="Include" ItemName="LocalTestContainer"/>
         <Output TaskParameter="Include" ItemName="TestContainer"/>
        </CreateItem>
    
        <Message Text="LocalTestContainer: @(LocalTestContainer)" Condition=" '$(IsDesktopBuild)'=='true' " />
        <!-- End workaround for TestContainer for TeamBuild + Desktop Builds -->
    

    I'm referring to:
    https://connect.microsoft.com/VisualStudio/feedback/details/324863/testcontainer-tests-dll-does-not-work-for-desktop-builds

    Does this fix your issue?

    Hope your issue will be clear soon.


    Forrest Guo | MSDN Community Support | Feedback to us

  • Friday, March 16, 2012 4:13 AM
     
     

    Hi,

    Thanks for the work around. But now i am encountering a new issue. What we are running is a desktop build and we have provided

    "Default Targets = "DeskTop Build" in the TFSBuild.Proj file. But the Condition "

    Task "TestToolsTask" skipped, due to false condition; ( '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' ) was evaluated as ( 'false'=='true' and 'false'!='true' and 'cTest1.dll != '' )."

    Shows IsDeskTopBuild as "False". In order to make it as true i have modified the Microsoft. TeamFoundation.Targets file with 

    <IsDesktopBuild>true</IsDesktopBuild>

    Still no scuccess. What could be the reason for this????

    In the workaround you have provided a path to fetch the test dlls <CreateItem Include="$(BinariesRoot)\$(Configuration)\*.Tests.dll">

    Can we provide any other path to fetch the test dlls???

    Appreciate your early response on this.

    Regards

    Sripriya

  • Sunday, March 18, 2012 7:36 AM
    Moderator
     
     

    Hi Sripriya,

    I have a few ideas about this:

    Hope your issue could get clear soon.

    Regards,


    Forrest Guo | MSDN Community Support | Feedback to us

  • Tuesday, March 20, 2012 7:03 AM
     
     

    Hi,

    Now i am able to use the TestToolTask. But the *.Tests.dlls are not being loaded in to the Binaries root which we have provided in the work around. Actually my test dlls are being copied in to the following folder $(SolutionRoot)\Source\out\release\bin\test. So i have tried to give the CreateItem to the folder where test dlls are located. But the logs show that the proj file is trying to locate the dlls from binaried folder.

    I have two questions now

    1. How do i get my test dlls to get copied from $(SolutionRoot)\Source\out\release\bin\test to $(BinariesRoot)\$(Configuration)

    2. Why is the tool trying to located dlls in binaries root even if i have set the path to solutionroot\source\out\release\bin\test.

    i have tried out the options given here too http://www.richard-banks.org/2009/11/how-to-build-vs2010-solutions-using.html

    Below is the exception

    Task "TestToolsTask" skipped, due to false condition; ( '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '%(LocalMetaDataFile.Identity)' != '' ) was evaluated as ( 'false'!='true' and 'false'!='true' and '' != '' ).
    Task "TestToolsTask" skipped, due to false condition; ( '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'=='true' and '%(LocalMetaDataFile.Identity)' != '' ) was evaluated as ( 'false'!='true' and 'false'=='true' and '' != '' ).
    Using "TestToolsTask" task from assembly "c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll".
    Task "TestToolsTask"
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1212,5): warning MSB4018: The "TestToolsTask" task failed unexpectedly. [c:\build\EpsilonA\32163\BuildType\TFSBuild.proj]
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1212,5): warning MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'file:///c:\build\EpsilonA\32163\Binaries\Release\Tests1.dll' or one of its dependencies. The system cannot find the file specified.



  • Tuesday, March 20, 2012 8:24 PM
    Owner
     
     Answered
    From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.

    Trevor Hancock (Microsoft)
    Please remember to "Mark As Answer" the replies that help.

  • Tuesday, April 03, 2012 7:14 AM
     
     

    Hi,

    The issue is resolved. After setting the proper copy commands, the build was executed successfully with the details of the unit test cases passed and failed. Thanks for the help provided.

    Regards

    Sripriya