views:

236

answers:

2

I have an NUnit test assembly (a .NET DLL). When I click Run in Visual Studio I want it to launch NUnit and run the tests in this assembly. I can do all of that.

Instead of specifying the full assembly name and path in the command line arguments, does Visual Studio support some sort of macro that expands into that for the Command Line Arguments box? Most other development tools I have used support this, but I cannot find anything in the documentation about this.

I was expecting something like: %assembly_full_path%

The reason I want to do this is so if the assembly name or build location changes, then I don't have to update the command line arguments as well.

+1  A: 

This doesn't work as far as I can tell. Macros in the Command Line arguments box do not get expanded. Not even environment variables. Bummer.

A workaround is to create a custom tool. Tools + External Tools, Add. Title = Run tests, Command = nunit.exe, Arguments = $(TargetPath), Initial Directory = $(TargetDir). Tweak as needed. You could assign a keystroke to this new tool command, even F5.

Hans Passant
I am going to accept this as the correct answer because I don't believe it is possible and you provided a good alternative. If someone else find a way to do it then I will accept that one. Thanks!
Jim McKeeth
Actually that didn't work. $(TargetPath) ends up being in the obj folder, and now the output path, so it doesn't run. Second of all, it doesn't not attach the debugger. Thanks though!
Jim McKeeth
Hans Passant
Excellent tips! Thanks.
Jim McKeeth
A: 

Using VS2005, the only item I need to provide in the Command Line Arguments is the name of the dll. I suspect VS sets the default working directory to the project's output directory, as I've never specified the path and yet the tests always load correctly.

Pedro