While executing my integration tests today, I was greeted with the excellent Assertion.Failed dialog which is displayed when using System.Diagnostics. This dialog caused a problem on the build server as it was waiting for someone to click Ignore – that someone never came!
If you haven’t saw the Debug.Assert code before, it basically looks like this:
public void DebugAssert()
When the Assert fails, the dialog is displayed.
The solution, add an App.Config file to your test suite. Within the XML will clear the trace listeners, now when assert is called nothing happens because nothing is listening for it and the code continues. While executing unit tests this is fine – we just don’t want the dialog being displayed.
If you was interested in the debug.assert messages, you could have hooked up a different listener to write out the message to the console or a file. This is what TestDriven.NET does, if an assertion is hit it writes the message to the output window.