Wednesday, May 14, 2008

Running xUnit Console inside VS Express IDE

I just downloaded the VS 2008 Express SP1 yesterday, and got excited because now the Visual Web Developer 2008 Express Edition supports Web Application and Class Library Projects, so more things can be done with the express edition, thanks to the VS Express team ;)

Usually we can use the unit test inside the VS IDE itself by using TestDriven.Net, however express edition will not support VS addins, so yeah it's the downside of it but anyway it's FREE, so live with it :P

I'm currently using xUnit which comes with a GUI interface and a console runner, i find it always better if we can use it inside the VS IDE itself without having to switch program using ALT+TAB to run the GUI / Console runner.

Wouldn't it be nicer if we can do it inside the IDE itself? So this is how i setup it in my VS IDE :
1. Go to Tools -> External Tools
2. Add new menu :

  • Title : x&Unit (& is used for shorcut keys)
  • Command : D:\Extension\xUnit\xunit.console.exe (This should be the your console runner location)
  • Arguments : $(BinDir)$(TargetName)$(TargetExt)
    **Updates : In VS2005 / VS2003 : $(ItemDir)bin\Debug\$(TargetName)$(TargetExt)
  • Check the Use Output window

Now in the Tools menu, you can find the new xUnit menu item.

So now, after you finish building the project, you only need to use the shortcut ALT T+U and it will out like this below :)


**Updates :
This is how to bind a keyboard shortcut to the unit test menu item, based on Distant Sounds's comment.
You will need to choose Tools.ExternalCommand(n), where n is the sequence order of your unit test menu item.
and then you get another option to execute the unit test ;)

Hope this helps ;)

5 comments:

Distantsound said...

Thanks for the neat idea, but I had trouble getting it to work. I changed the arguments field to $(ItemDir)bin\Debug\$(TargetName)$(TargetExt) and it started working

Anonymous said...

BTW, you can assign a more convinient shortcut via Tools -> Customize -> Keyboard menu. Try searching for "External Tool x" in the list of available commands.

Bembeng Arifin said...

Hi,
Thanks for the comment, I've added your shortcut suggestion into the post ;)

Anonymous said...

Nice, very useful. Thanks.

Unknown said...
This comment has been removed by the author.

Post a Comment