views:

518

answers:

1

Using Visual Studio / C#, I've been debugging some nunit tests recently, and am now trying to make sure that if we branch the code that the unit tests don't stop working in debug mode.

I have this working by changing project properties to launch NUnit as an external program:

C:\Program Files\NUnit 2.4.8\bin\nunit-console.exe

..and then set my .nunit config:

D:\SomePath\branches\NewFeatureBranch\TestDSP.nunit

So now I'd like to make that path generic. I thought something like this should work:

$(SolutionDir)\$(ProjectName).nunit

...but NUnit exits before running the test. Those variables don't appear to get sent though as a quick console app tells me:

arg[0] = D:\Projects\Tools\ArgDebugger\Debug\ArgDebugger.exe
arg[1] = $(SolutionDir)\$(ProjectName).nunit

Is there another way I can feed that information?

A: 

Well when I build two console apps.

App2 is debugged with App1. In App1 System.IO.Directory.GetCurrentDirectory() gives

Solution\Project\Bin\Debug of App2.

Therefore putting *..\..\..\* into the Working Directory of App2 gives me

*Solution\* of App2. So you can then change the path to the .nunit file to be ./TestDSP.nunit

Simeon Pilgrim
That's certainly an option - thanks. Still feels slightly cludgy, but definitely better than hardcoded paths!
Jon Cage
As long as your paths are relative hardcoded, having many branches or copies of one branch will work.
Simeon Pilgrim
I agree; it will definitely work for my current project structure :-)
Jon Cage