Today I upgraded my solution with all the underlying projects from VS2008 to VS2010. Everything went well except for my unit tests.
First of all only the web project
Make sure your reference to Microsoft.VisualStudio.QualityTools.UnitTestingFramework is Version 10.0.0.0.
If it is version 9.0.0.0 this problem will occur in Visual Studio 2010.
Hope this helps. If people still have this problem.
I've had the same issue, but finally managed to get it working. Not really sure how but here's a list of things I did between it not working to when it started working again.
Not sure which bit fixed it though. Anyway, hope this helps!
I ended up changing my tests to this form to avoid the breaking. Not ideal:
[TestMethod]
public void Guid()
{
try
{
Guid g = new Guid("myguid'123'");
}
catch( FormatException fe)
{
return; // expected exception - pass
}
Assert.Fail(); // exception not thrown - fail
}
Gerrie pointed me in the right direction:
This will get rid of the break on failed Asserts, but the test will still break when you have set an ExpectedException.
I was the one that set the 100 bonus for this, so some upvotes would be appreciated ;-)
According to Microsoft, this is not a bug, it's "by design":
http://connect.microsoft.com/VisualStudio/feedback/details/511897/expectedexception-still-causes-debugging-to-break-with-exception-was-unhandled-by-user-code
A Microsoft support guy told me to use Ctrl-F5 (start without debugging) when running my unit tests, and that seems to work.
Another thing to try is to go to Tools|Options|Debugging and un-check the "Enable Just My Code" option.