chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I am having a problem running Typemock Isolated tests from VS.Net 2012. I can run the tests fine with testdriven.net but I cannot run them through Microsoft's test runner. I got back an error indicating that Typemock needs to be enabled.

TypeMock.TypeMockException:
*** Typemock Isolator is not currently enabled.
To enable do one of the following:

* To run Typemock Isolator as part of an automated process you can:
- run tests via TMockRunner.exe command line tool
- use 'TypeMockStart' tasks for MSBuild or NAnt

* To work with Typemock Isolator inside Visual Studio.NET:
set Tools->Enable Typemock Isolator from within Visual Studio

For more information consult the documentation (see 'Running' topic)
Result StackTrace:
at gn.a()
at gn.d()
at TypeMock.MockManager.Init(Boolean collectAllCalls)
at TypeMock.MockManager.Init()
at TypeMock.RecorderManager.a(RecordExpectations A_0)
at TypeMock.RecordExpectations..ctor()
at TypeMock.RecorderManager.StartRecording()
at GameFly.UnitTest.Commons.Logging.HttpExcludeFixture.AcceptsAllowedReferrer()


I do not see any option to enable typemock from the tools menu. I believe Typemock should be running because I have the option to "suspend mocking" from the typemock menu.

I also get errors from Typemocks test runner.
Failure:
System.InvalidProgramException : Common Language Runtime detected an invalid program.

I have the latest version of Typemock.

Please let me know what further information I can provide to help resolve this issue.

Thanks,
Jesse
asked by jnapier (9.6k points)

14 Answers

0 votes
Yes.

Isolator will also include automatic linking with many 3rd party profilers while running inside Visual-Studio. For example VS coverage profiler or IntelliTrace will be linked without requiring any explicit settings.
answered by Elisha (12k points)
0 votes
Hi Elisha,

Thanks for your reply.

Will TypeMock also then work correctly with the .runsettings file used by msbuild 2012?
answered by dblack (8.4k points)
0 votes
Hi,

I assume you mean to SmartRunner.
SmartRunner will support more features defined by MSTest Run Settings - it'll cover most deployment items settings.
Tests that use Isolator APIs already support Run Settings while being executed in MSTest runner.
answered by Elisha (12k points)
0 votes
Not SmartRunner - just running mocked tests (locally or on a build server) using a .runsettings file instead of a .testsettings file (which is now considered obsolete by VS2012).

If I run unit tests under the following .runsettings file, I get this message in the Test Results window and no tests are executed.

------ Run test started ------
Exception has been thrown by the target of an invocation.
========== Run test finished: 0 run (0:00:03.9063906) ==========

This .runsettings causes the above error:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
   <!-- Configurations that affect the Test Framework -->
   <RunConfiguration>
      <!-- Path relative to solution directory -->
      <ResultsDirectory>.TestResults</ResultsDirectory>

      <!-- [x86] | x64  
     - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
      <TargetPlatform>x86</TargetPlatform>

      <!-- Framework35 | [Framework40] | Framework45 -->
      <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
   </RunConfiguration>

   <!-- Configurations for data collectors -->

   <DataCollectionRunSettings>
      <DataCollectors>
         <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
            <Configuration>
               <CodeCoverage>
                  <ModulePaths>
                     <Include>
                        <ModulePath>foo.*</ModulePath>
                     </Include>
                     <Exclude>
                        <ModulePath>.**test*.dll</ModulePath>
                     </Exclude>
                  </ModulePaths>
               </CodeCoverage>
            </Configuration>
         </DataCollector>
      </DataCollectors>
   </DataCollectionRunSettings>

   <!-- Adapter Specific sections -->

   <!-- MSTest adapter -->
   <MSTest>
      <!--<IgnoreTestImpact>true</IgnoreTestImpact>-->
      <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
      <CaptureTraceOutput>false</CaptureTraceOutput>
      <DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
      <DeploymentEnabled>False</DeploymentEnabled>  <!-- TODO: come back after this file is figured out and then try running unit tests directly in the build output directory -->
   </MSTest>
</RunSettings>


However, if I comment out the code coverage section (see .runsettings below), everything works. I was assuming this is because of some of the problems TypeMock has with VS2012 (note that I am still using v7.0.9) and was hoping this error has been/will be fixed in the latest release.

This .runsettings file works - note that I have commented-out the 'CodeCoverage' section:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
   <!-- Configurations that affect the Test Framework -->
   <RunConfiguration>
      <!-- Path relative to solution directory -->
      <ResultsDirectory>.TestResults</ResultsDirectory>

      <!-- [x86] | x64  
     - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
      <TargetPlatform>x86</TargetPlatform>

      <!-- Framework35 | [Framework40] | Framework45 -->
      <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
   </RunConfiguration>

   <!-- Configurations for data collectors -->

   <DataCollectionRunSettings>
      <DataCollectors>
         <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
            <Configuration>
               <!--<CodeCoverage>
                  <ModulePaths>
                     <Include>
                        <ModulePath>foo.*</ModulePath>
                     </Include>
                     <Exclude>
                        <ModulePath>.**test*.dll</ModulePath>
                     </Exclude>
                  </ModulePaths>
               </CodeCoverage>-->
            </Configuration>
         </DataCollector>
      </DataCollectors>
   </DataCollectionRunSettings>

   <!-- Adapter Specific sections -->

   <!-- MSTest adapter -->
   <MSTest>
      <!--<IgnoreTestImpact>true</IgnoreTestImpact>-->
      <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
      <CaptureTraceOutput>false</CaptureTraceOutput>
      <DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
      <DeploymentEnabled>False</Deplo
answered by dblack (8.4k points)
...