Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered TFS 2010 Build Automation and Unit Test with Moles Problem

  • Friday, September 21, 2012 9:46 PM
     
     

    I am trying to create a build to run unit tests using TFS 2010.  If I run the all the unit tests locally in VS 2010, they all work.  When I run them through the build, I get 200+ errors related to the following:

    The test adapter 'MolesAgentAdapter' threw an exception while running test. Object reference not set to an instance of an object.

    Moles (latest) has been installed on the build agent.  Does anyone have an idea what causes this and where I should be looking to fix it?


    -7

All Replies

  • Monday, September 24, 2012 9:07 AM
    Moderator
     
     

    Hi smyrin,

    Thanks for your post!

    From your description, you can run the build with unit tests locally in VS 2010, and not work on Team Build.

    Can you tell me if you have installed the VS 2010 in the Build machine? You must have Team Edition for Testers installed on the computer that will act as your build agent. Please refer to

    http://msdn.microsoft.com/en-us/library/cc981972%28v=vs.90%29.aspx

    For more information about Visual Studio, please refer to http://www.microsoft.com/visualstudio/en-gb/products

    Hope it helps!

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, September 24, 2012 3:16 PM
     
     
    I have everything installed on the build agent that is needed.  I can manually invoke MSTest and get a successful run so I am focusing my attention to the unit test themselves at this time.  I will advise when I know more.

    -7

  • Tuesday, September 25, 2012 3:05 AM
    Moderator
     
     Proposed

    Hi smyrin,

    Thanks for your feedback!

    We will be appreciated if you can share the experiences here.

    For this issue, I think you can view the build log from the build report, and type the key word "MSTest" and see if there is more related error there.

    Hope it helps!

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, October 01, 2012 9:25 AM
    Moderator
     
     

    Hi smyrin,

    How about the issue, is it solved?

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, October 01, 2012 3:53 PM
     
     
    No not solved yet.  Moles is still an issue on the build machine.  It works when I build locally.  Might have something to do with code coverage as I get better results when I turn that off.

    -7

  • Tuesday, October 02, 2012 9:17 AM
    Moderator
     
     

    Hi smyrin,

    Thanks for your feedback!

    Do you mean you select Test --> Edit Test Settings --> Local Test Settings --> disable Code Coverage, then the team build can work well?

    Have you tell the build server which test settings file is to use?  You will find this in the build settings under  Process >2. Basic >Automated Tests >1. Test Assembly >TestSettings file.

    Please read this blog http://www.codewrecks.com/blog/index.php/2010/06/14/running-code-coverage-in-tfs2010-builds/ for more help.

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, October 02, 2012 3:08 PM
     
     

    When I turn off all the code coverage, I get 100% pass rate.  When code coverage is on, I get a number of moles related errors:

    The test adapter 'MolesAgentAdapter' threw an exception while running test. Object reference not set to an instance of an object.

    I am familiar enough with the builds to know how to use the test settings file and how to point the build at it.  MSTest and Moles + Code coverage do not get along well together.  Still don't know why.


    -7

  • Wednesday, October 03, 2012 8:59 AM
    Moderator
     
     

    Hi smyrin,

    Thanks for your feedback! I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thank you for your understanding and support.

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, October 04, 2012 1:31 AM
    Moderator
     
     

    Hi smyrin,

    Just to confirm... this is the latest Moles install?

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, October 04, 2012 3:20 PM
     
     
    Yes.  0.94.51023.0

    -7

  • Monday, October 08, 2012 9:16 AM
    Moderator
     
     Answered

    Hi smyrin,

    Thanks for your feedback!

    This may be related to Coverage causing multiple Profilers to load, as I believe Moles utilizes profiler aspects and coverage does as well. 

    It looks like the code coverage instrumentation is creating an issue with the Moles adapter. There is no other fix than disabling code coverage while running tests with Moles.


    The preferred option I think is to migrate to Fakes – which was designed to handle Moles+Coverage scenarios properly.

    In addition, can you tell me what happens when you enables coverage metrics locally while running the moled unit tests?

    Can you check Windows Application EventLog on build server as well as capturing detailed output from unit tests. There's likely more detailed info to be found about the failure.

    Hope it helps!

    Best Regards,


    Cathy Kong [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, March 07, 2013 8:58 PM
     
     

    Moles seems to support Chaining multiple CLR profilers. 

    PS note from Peli ( Microsoft Research ).. 

    http://social.msdn.microsoft.com/Forums/en/pex/thread/9b2f683c-d73e-49f4-b35a-c424dc509791

    Would be great if we could use the same technique to have the CodeCoverage profiler chained to the Moles profiler ? Just need to figure out the ClassId of the CodeCoverage profiler.  

      set CLRMONITOR_EXTERNAL_PROFILERS=<CodeCoverage Profiler GUID>

    Any Thoughts ?