Use Debug fail method
using System; using System.Collections; using System.Diagnostics; class Class1 { static void Main(string[] args) { Debug.Fail("Fail Message", "An unexpected exception has been thrown.\n\n"); } }