Test runner executed builds (is there a difference?)

I'm trying to run unit tests on every build and I have NUnit from the MSBuild community tasks doing that job.   The problem is that I'm executing the tests twice when I decide I want to use the resharper test runner and it rebuilds my test project.   Is there any way to tell (from MSBuild) that resharper test runner is executing the build.  An enviornment variable, property or condition that I might be able to check??

Any help or pointer in the right direction would be great.

Environment:
- Windows Vista x64 SP1. UAC disabled
- Resharper 4.1 licenced
- VS 2008 SP1

Thanks

2 comments

Hello,

I'm trying to run unit tests on every build and I have NUnit from the
MSBuild community tasks doing that job. The problem is that I'm
executing the tests twice when I decide I want to use the resharper
test runner and it rebuilds my test project. Is there any way to
tell (from MSBuild) that resharper test runner is executing the build.

An enviornment variable,

property or condition that I might be able to check??


Is a continuous integration server (such as TeamCity) running the tests for
you on each checkin, or are the tests included within the compilation of
your project?

The latter is a strange case. However, if the compilation is running the
tests on its own, then the R# unit test runner is not executing yet, it's
waiting for the build, so probably there's no way to tell that it's going
to run something when the build completes.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Thanks for your quick reply.  I went on holiday and just returned.  I think you answered my question but I'd love to be clear just in case.

Is a continuous integration server (such as TeamCity) running the tests for
you on each checkin, or are the tests included within the compilation of

your project?


Both.  I have TeamCity and it swaps out the msbuild NUnit task for it's own test runner.  This works fine.

The tests will also run when someone opens the solution and does a CTRL+SHIFT+B build from the Debug/Release configuration.  When the unit test project is built the PostBuild target will fire off the msbuild NUnit task and run the tests.  This works great except when I want to use the R# test runner.   R# will build the unit test project and at the end of that build it will fire the msbuild NUnit test runner then it will finally execute the R# test runner.

... However, if the compilation is running the
tests on its own, then the R# unit test runner is not executing yet, it's
waiting for the build, so probably there's no way to tell that it's going
to run something when the build completes.


If R# does or could somehow set a conditional compilation symbol then I'd be able to test for it's existence within the msbuild and not run the msbuild NUnit task.   I'd guess that this is currently not possible with R# as it probably doesn't mess with anything in the build before telling visual studio to do it's thing.

I did think of a work-a-round that will suffice (but is not ideal IMHO).   I've added a solution configuration called DebugResharperTest that I can select before I click on the resharper test runner.  All other build configurations will run the tests automatically.  I just dislike adding non-standard solution configurations and I work with a team that is very much a visual studio CTRL+SHIFT+B culture.  Unit tests are a newer idea for us so we're working through the culture change slowly.

Thanks for your help.

0

Please sign in to leave a comment.