Wednesday, December 02, 2009

How to disable assert dialogs while testing (.net)

Why would you want to do that in the first place? Let’s say you have a complex (long) test you want to run in your application, so you decided to start it before going home so it’ll be ready tomorrow morning with the results. What would happen if when get to you computer the next morning you find an assert dialog waiting for you to “Abort”, “Retry” or “Ignore”? Believe me, it is frustrating and irritable!
I had a few “alternative ways” to ignore those asserts ( but Willy told me the correct way to do it.
All you have to do is adding the following to your .exe.config file:

    <assert assertuienabled="false"/>

That code tells the framework that you don’t want to show a message box when a “Debug.Assert” is called, which is exactly what I wanted.

So, since my test is a msbuild script all I had to do is adding the above “code” in the msbuild.exe.config and now my tests runs smooth and the results are ready, waiting for me :)

More info on the assert tag here.


Unknown said...

Thanks for the tip, you are a life saver ^^

ase said...

Thanks for the tip, you are a lifesaver ^^