locked
ShimsContext not working from Test Menu RRS feed

  • Question

  • We are trying to use ShimsContext for creation of an object and using a property. It is a normal class(does not inherit from interface/abstract) which cannot be changed. When we use the example provided in MSDN, we were able to run the tests using Debug->Tests. When we try to use Test Menu and run Analyze Code Coverage, the tests fail and code coverage is also not showing up properly even though it executes all other tests(which are not using Shims) successfully. If we select the tests in test explorer, right click and run all the tests including ones using Shimscontext pass and code coverage is showing currently. Not so sure of this problem. Could not find the reason when searched web also. We have set up a build definition and worried whether the build will run successfully when the code is checked in. We are using VS 2013,TFS 2013 and .runsettings(it has only code coverage settings configured).  It is trying to access the original class and fails instead of shim

    Any help is appreciated

    Saturday, June 27, 2015 5:10 PM

Answers

  • Hi K.P.Kannan,

    Generally, I know that when we run Analyze Code Coverage from the Test Menu or Test Expolrer in the VS IDE, we will not need to call the setting file.

    So if you call the .runsetting file to run Analyze Code Coverage from the Test Menu or Test Explorer in the VS, please try to disable the .runsettings file and then run Analyze Code Coverage from the Test Menu check this issue again.

    In addition, I tried to write a simple ShimsContext sample and then run Analyze Code Coverage from the Test Menu or Test Explorer, I get same code coverage result in the Test Menu and Test Explorer like the following screen shot.

    I suggest you could also try to right-click your unit test project and then select clean->rebuild project, then run Analyze Code Coverage from the Test Menu check this issue again.

    If the above suggestion still could not help you, I suggest you could share me your code about this ShimsContext so that we will help you reproduce this issue.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Tina-Shi Monday, July 6, 2015 9:22 AM
    Monday, June 29, 2015 10:12 AM