How to launch app so that it can be VS debugged

Jan 17, 2012 at 9:03 PM

Hi,

I have a WPF app that I'm launching from an NUnit test using White and I wish to be able to run the tests, from Visual Studio 2010, in debug mode so I can use break points. How can I do this?

I'm launching the app with (White's Application class):

var application = Application.Launch(path);

I run my tests from VS via Resharper. I can put break points in the test code but not the application that the tests are running.

 

Thx

Rob Smyth

Jan 18, 2012 at 7:48 AM
Edited Jan 18, 2012 at 7:50 AM

what do you want to debug? the test or the application?

if you want to debug the application under test:

 

open a second instance of VS and load sources of the application, attach debugger of VS to the running application, and set breakpoints.

 

Throndorin

Jan 18, 2012 at 9:53 AM
Throndorin wrote:

what do you want to debug? the test or the application?

if you want to debug the application under test:

 

open a second instance of VS and load sources of the application, attach debugger of VS to the running application, and set breakpoints.

 

Throndorin

Hi Throndorin,

I want to test the application under test.

To open a second intance of VS is kinda too late. The instance is only there after the test starts and I want to know why the test is failing. I frequently have cases where the automated tests, as they are fast, show up defects. I want to run the tests in debug (from Resharper) with break on exception thrown so I can view the call stack, etc.

Thx

Rob Smyth

Jan 18, 2012 at 9:58 AM

yeah right :)

 

ok Step by step

open 2 VS (one with the app solution and one with the test solution)

set breakpoint in test after application launches and debug the test. The tests wait and the application has started => right?

set breakpoint in the app under test and attach debugger to running app.

 

now continue with test execution

Jan 19, 2012 at 8:02 AM
Throndorin wrote:

yeah right :)

 

ok Step by step

open 2 VS (one with the app solution and one with the test solution)

set breakpoint in test after application launches and debug the test. The tests wait and the application has started => right?

set breakpoint in the app under test and attach debugger to running app.

 

now continue with test execution

Hi ... thx .. but

All projects, both production and test, are in the one solution. Having two solutions is something to consider but not desirable. We run our tests from within Visual Studio's IDE using Resharper. Want to run the test in debug mode with VS Debug | Excpetions break on all set so that when an exception occurs VS shows the line immediately. Nice, simple, fast. I want to get team member acceptance.

Thing is we do not feel any need to test, in all tests, that Windows can launch an EXE. So if we could open the main window in the running test application then all would be good in the world. But I hit the problem of giving CPU time to the window. Can do up to the point of calling UIItem.Click. I've tried adding a wait handler but that just does not do it.

If I can do this I can run all our UATs, not as a separate app, but as a window from the test app. Faster (was when I did this on WinForm apps) and easier to debug.

 

Thx again

Rob