private static void ExceptionTest(string filename, string expectedTitle, string expectedDescription, string exceptionType, int expectedLine) { using (var app = new VisualStudioApp()) { var debug3 = (Debugger3)app.Dte.Debugger; bool justMyCode = (bool)app.Dte.Properties["Debugging", "General"].Item("EnableJustMyCode").Value; app.Dte.Properties["Debugging", "General"].Item("EnableJustMyCode").Value = true; try { OpenDebuggerProject(app, filename); var exceptionSettings = debug3.ExceptionGroups.Item("Python Exceptions"); exceptionSettings.SetBreakWhenThrown(true, exceptionSettings.Item(exceptionType)); app.Dte.ExecuteCommand("Debug.Start"); WaitForMode(app, dbgDebugMode.dbgBreakMode); exceptionSettings.SetBreakWhenThrown(false, exceptionSettings.Item(exceptionType)); exceptionSettings.SetBreakWhenThrown(true, exceptionSettings.Item(exceptionType)); debug3.ExceptionGroups.ResetAll(); var excepDialog = app.WaitForException(); AutomationWrapper.DumpElement(excepDialog.Element); Assert.AreEqual(expectedDescription, excepDialog.Description); Assert.AreEqual(expectedTitle, excepDialog.Title); excepDialog.Cancel(); Assert.AreEqual((uint)expectedLine, ((StackFrame2)debug3.CurrentThread.StackFrames.Item(1)).LineNumber); debug3.Go(WaitForBreakOrEnd: true); WaitForMode(app, dbgDebugMode.dbgDesignMode); } finally { app.Dte.Properties["Debugging", "General"].Item("EnableJustMyCode").Value = true; } } }