Attaching the debugger to nUnit

I'm doing some heavy refactoring of a prototype using a bunch of tests in nUnit to keep things sane.

When tests fail for what seem to be strange reasons, I use attach to process to attach to the running nUnit rather than using the start button and lauching an new instance. I also use attach like this to avoid recompiling-restarting a web app.

Having reduced it to key strokes (Alt+D P, N, Enter ), I thought I would try a macro instead. I ususaly have problems with recorded macros.

I recorded it and when I executed it, it attached to the process, but wasn't deguggin anything, they Type column was empty instead of Being "T-SQL, Managed".

I played a little with the macro to change the engines used and presto: one button to attach to the first nUnit instance.

The macro

Edited to remove "Native" so that VS doesn't terminate nUnit

     Sub nUnitDebug()
        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim dbgeng(10) As EnvDTE80.Engine
            Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "ML-ANDREW-SRV").Item("nunit-gui.exe")
            Dim myEngine As Engine
            '     Dim strEngineList As String
            Dim indexer As Integer = 0
            For Each myEngine In trans.Engines
                '    strEngineList = strEngineList + myEngine.Name + ", " + _
                '   myEngine.ID(+", " + myEngine.AttachResult.ToString + System.Environment.NewLine)
                If myEngine.Name.Contains("Managed") Then
                    If myEngine.Name.Contains("Native") = False Then

                        dbgeng(indexer) = myEngine
                        indexer += 1
                        'redim preserve dbgeng)(
                        '       MsgBox("Adding" + myEngine.Name + "::" + myEngine.ID)
                    End If
                End If
            Next
            'MsgBox(strEngineList)

            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try

    End Sub

 

 

 

1 Comment

Comments have been disabled for this content.