Lately, I have been doing Test Driven development in my development projects. I have noticed a strange issue which occurs especially when the code coverage is enabled for the assemblies. The result is , unit tests works normally in Debug mode and do not behave as expected when run in Normal mode.
I have noticed the bug logged for this on Connect website:
Meanwhile, the workaround for this is to do a full release build of the solution before running unit tests in Normal mode.I guess this is because, Normal run uses the release version of assemblies as opposed to Debug versions, and if the Release assemblies are either old or missing, they are bound to fail.
Rory had left a comment on this post and provided the excellent and absolute solution for this. This is quoted in his own words and here is the link to his blog post. Thanks Rory !!!
The issue is encountered because the testrunconfig points code coverage at assemblies using a relative path that includes the build configuration output directory.
If the testrunconfig points to bin\Debug\YourAssembly.dll and you make a change to the methods in Debug and a test for it, then change to Release without a Debug build and run the unit tests, then the new tests won't find the methods in the assembly identified in the code coverage configuration.
The fix is to manually edit the testrunconfig to replace the build configuration part of the path with $(OutDir). This will mean that the assemblies will work with any build configuration.
PingBack from http://www.codedstyle.com/systemmissingmethodexception-method-not-found-when-running-unit-tests/
Thanks for the perfect solution Rory. I will update my post to include your solution and a link to your blog post as well :)