views:

58

answers:

3

Is there any easy way to automatically run my unit tests after a successful compilation?

+2  A: 

Yes, but probably you don't want to. This is generally done on a CI server (i.e. your build server) or on an ad-hoc basis.

But if you really want to try it out, in VS you can execute the tests as a "Post Build" task. You can just specify a command-line to run (i.e. nunit) and then direct it to the appropriate lib (there are special variables that will let you link to the just-built project dll).

Noon Silk
what's the command line?
An executable. Right-click on the properties of a project and go t 'Build Events'. In the post build you can write something like: `"$(ProjectDir)..\nant\nant" -buildfile:"$(ProjectDir)..\local.deploy.task" -D:startingPath="$(ProjectDir)\"` (that's taken from one of our projects).
Noon Silk
+2  A: 

Think about it the other way around: instead of running unit tests each time you compile, simply get into the habit of running the unit tests often.

If you are using MSTest in Visual Studio, you can run all the unit tests as easy as Ctrl+R, A. When you do that, VS automatically compiles the code before running the tests.

Mark Seemann
Even better, thanks
A: 

Take a look at Tree Surgeion on codeplex.com

davidylam