I have a project that uses the NUnit framework (v2.6.3) to define several unit tests and uses TypeMock Isolator to create fake objects. When I run these tests from the TypeMock shield icon next to the test, they run fine. When I run the tests using dotCover's "Cover Unit Test with dotCover" menu item, they run fine. However, when I try to run them with dotCover's "Run Unit Tests" or "Debug Unit Tests" menu items, they fail with this error:
Test method UnitTests.UnitTests.TestMethod1 threw exception:
*** Typemock Isolator is currently disabled. Enable using the following:
at TypeMock.MockManager.Init(Boolean collectAllCalls)
Tests that don't use Isolator run fine with this method. Only those that use Isolator fail.
After decompiling and debugging the TypeMock assemblies, it looks like the reason is twofold:
1) The TMOCK_RUNNING_VERSION environment variable is "18.104.22.168" when running from the Smart-Runner (TypeMock runner), but is null when running under dotCover.
2) The TMOCK_PID environment variable is set to the PID when running normally, but is null when running under dotCover.
If I set these values manually while debugging the tests, the tests run fine. So for some reason, these environment variables are not getting set with that run/debug method. On the other hand, apparently nobody cares except for the TypeMock validation code which throws these exceptions. The TypeMock.Interceptors dll is loaded and works fine, the test runs fine.
The problem also occurs when running test that use the MSTest framework and when using Visual Studio's runner (Test->Run menu item). So this appears to be an issue in TypeMock itself.
Here's my setup:
Windows 7 Professional
Visual Studio 2010 (Identical results with VS 2012)
TypeMock v22.214.171.124 "Essential" Edition (Installed on local machine, *not* using AutoDeploy)
I've played with just about every setting there is. Results are identical. A short list is:
Enabling/disabling "Enable mocking for 3rd party runners". (no difference)
Manually linking using the TypeMock Isolator configuration tool. (no difference)
Enabling/disabling "Disable auto linking" in configuration tool. (no difference)
Banging my head repeatedly on my keyboard. (head hurt afterwords, no difference in test results)
Anyone have any ideas here? I've seen lots and lots of similar questions, but no answers that work for me.