There’s something a little peculiar about how unit tests work in Silverlight when the debugger is attached – when an Assert fails in one of your unit tests, the Visual Studio debugger breaks the execution and brings up the debugger dialog.
If you want to run a whole bunch of unit tests to see which ones are failing or you only care about the exceptions that your code throws, this feature can really cramp your style. Thankfully, it’s pretty easy to edit the debugger settings to make these Assert exceptions go away.
Step #1: Go to the Debug menu in Visual Studio 2010, choose Exceptions…
Step #2: On the Exceptions dialog, click Add…
Step #3: Register the exception types you want to tweek
From the Type menu, choose Common Language Runtime Exceptions.
In the Name textbox, type Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException.
Click OK.
Step #4: Repeat step #2 and #3 for Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException
Step #5: Uncheck Thrown and User-unhandled for the exceptions you just added.
Step #6: On the Exceptions dialog, click OK
Step #7: Enjoy your new streamlined exceptions.
-Ben
Leave a Reply