Tips & Tricks: Set the output type to EXE and give it a main method

Ok, you’ve written your tests, and you want to debug them or you’ve got a test failing and you can’t quite see why. What are you gonna do? Well, right now we don’t have built in support for debugging of tests, but there is a sneaky workaround that I use a lot.

 

Because all our projects are just derivatives of the normal projects, you can set the same options. This means that you can turn the project into an EXE type rather than just a class library. Because it’s an EXE you can create a main method and allow F5 execution. Because the unit test framework works with any ol’ assembly you can still execute the tests from test view, even with a EXE rather than DLL.

 

One other sneaky trick I’ve thought about, but not gotten round to doing is setting mstest.exe as the command line for the debug session, and seeing if that would work. But As I say, I’ve not tried it yet – if It works, please share :)

 

UPDATE: Sorry, I should have made it clearer, this is a Tip for the May CTP - we're intending on adding full support for debugging tests, it's just it's not in there right now.