I am currently using the Nunit launcher to run my unit tests, and some of these tests require TypeMock to be enabled (easily done by setting some environment variables). However, I have recently added some other tests that cannot be be run when TypeMock is enabled. So, what I wanted to do in my build script was to:
1) Enable TypeMock (i.e. set some environment variables)
2) Run only those tests that require TypeMock (using the /category-include: argument for nunit launcher)
3) Disable TypeMock (i.e unset some environment variables)
4) Run only those tests that don't require TypeMock (again using /category:include)
However, when I try this the tests in 2) all fail because TypeMock is not enabled.
I then tried setting the environment variables as part of the build configuration. In this case I get a failure at 4), because TypeMock has not in fact been disabled.
I assume the problem is that TeamCity only reads the environment variables once before it starts a build and does not notice the changes? Is this correct? And is there any way I can force the environment variables to be reloaded during the build?