Welcome to MSDN Blogs Sign in | Join | Help

System.MissingMethodException: Method Not Found when running unit Tests

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:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=123306

 

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.

 

[Update 6/01/09]

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.

See http://www.neovolve.com/post/2008/01/30/incorrect-code-coverage-references-in-testrunconfig.aspx

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.

Published Sunday, January 04, 2009 12:54 PM by Madhur
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# System.MissingMethodException: Method Not Found when running unit Tests | Coded Style

# re: System.MissingMethodException: Method Not Found when running unit Tests

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.

See http://www.neovolve.com/post/2008/01/30/incorrect-code-coverage-references-in-testrunconfig.aspx

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.

Sunday, January 04, 2009 4:21 PM by Rory Primrose

# re: System.MissingMethodException: 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 :)

Madhur

Monday, January 05, 2009 1:15 AM by Madhur

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker