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
Hi,

We have recently migrated our entire unit test suite from NUnit to MSTest 2008. All the tests run fine from within Visual Studio 2008 with the TypeMock add-in enabled.
However, on our build server (running CCNet), all tests using TypeMock now fail with the following exception:

TypeMock.TypeMockException: TypeMock.TypeMockException: *** TypeMock.NET is not enabled, to enable do one of the following: 1. run 'mocking_on.bat' before running the tests 2. run tests via TMockRunner.exe 3. use TypeMockStart tasks for MSBuild or NAnt 4. set Tools->Enable TypeMock.NET from within Visual Studio For more information consult the documentation (see Running topic)

Here is the portion of our NAnt build script which runs the tests:

<typemockstart link="NCover" profilerlaunchedfirst="true" target="2.0" />
<ncover
    workingDirectory="."
    program="${ncover.path}"
    profiledProcessModule="VSTestHost.exe"
    commandLineExe="${mstest.path}"
    commandLineArgs="/testcontainer:${mstest.library.path} /runconfig:${mstest.project.path} /resultsfile:${output.dir}\mstest.log"
    coverageFile="${output.dir}\ncover.log"
    logFile="${output.dir}\coverage.log"
    failonerror="true">
        <assemblies basedir=".">
             <include name="**/${application.base.namespace}*.dll" />
             <exclude name="**/${application.base.namespace}*Tests.dll" />
        </assemblies>
</ncover>
<typemockstop />


We are using NCover 1.5.5 Beta and TypeMock.NET 4.1.0.0. Note that when running the tests in the development environment, TypeMock is not linked to any code coverage profiler.
What are we doing wrong here?

Thanks in advance,
/Enrico
asked by megakemp (3k points)

8 Answers

0 votes
Hi Enrico,

I would like to refer you to this thread:
https://www.typemock.com/community/viewtopic.php?t=486

I am not all that sure that NCover 1.5.5 supports working with MStests and typeMock. (at least we had problem with it when trying to work with VS2005).

I would try to verify that this is the problem by disabling coverage on the server.
If that works try running your test with NCover enabled but without TypeMock.

If that works also I would assume that this is indeed the integration problem and would try checking out the new NCover 2.0.1. That version should do the trick.

In any case let me know if we can assist in this process.
answered by lior (13.2k points)
0 votes
Hi Lior,

I have now changed our build script to run MSTest without code coverage, but I am still getting the same error.
The relevant portion of the build script looks like this:
<typemockstart profilerlaunchedfirst="true" target="2.0" />
    <exec
        program="${mstest.path}"
        failonerror="true">
            <arg value="/testcontainer:${mstest.library.path}" />
            <arg value="/runconfig:${mstest.project.path}" />
            <arg value="/resultsfile:${output.dir}\mstest.log" />
    </exec>
<typemockstop />


I even tried to run MSTest in-process, by specifying the /noisolation option, but that didn't help.
Do you know what the problem could be here?

Thanks in advance,
/Enrico
answered by megakemp (3k points)
0 votes
Hi Enrico,

:idea: remove the profilerlaunchedfirst attribute
:idea: the target attribute is also not needed because mstest works only in .net 2.0+
<typemockstart/>
<exec .../>
<typemockstop/>


:arrow: You can also take a look at the CC.NET plugin for TypeMock (this is used for running with the native CC.NET unit tests) Download from this post
answered by scott (32k points)
0 votes
Hi Scott,

I have removed all the attributes from the TypeMockStart NAnt task, but I am still getting the same error. I tried to enable logging but that didn't work because of a bug in TypeMockStartTask (I reported it on https://www.typemock.com/community/viewtopic.php?t=639), so I can't provide you with any more detailed information.

Are there any known compatibility issues between TypeMock 4.1 and MSTest 2008?

Thanks in advance,
/Enrico
answered by megakemp (3k points)
0 votes
Enrico hi,

Can you try to see if you can produce the log by removing the log level and specifiying instead the logpath?
For the meantime this should enable you to produce the logs so we can check what exactly goes wrong in you setup.
Also In your build server have you installed typemock or are you using the Auto Deploy capability of typemock?

Currently no one (besides you of course) has reported any compatibility issue with 2008 that seems to be relevant.

BTW I'm assuming that you are using the 2008 release and not one of the previous beta versions.
answered by lior (13.2k points)
0 votes
Hi,

We have now upgraded to NCover 2.0.3, and here is how we run unit tests in our build script:
<typemockstart link="NCover2.0" />
        <ncover
            program="${ncover.path}"
            profiledProcessModule="VsTestHost.exe"
            commandLineExe="${mstest.path}"
            commandLineArgs="/testcontainer:${mstest.library.path} /runconfig:${mstest.project.path} /resultsfile:${output.dir}\mstest.log"
            coverageFile="${output.dir}\ncover.log"
            logFile="${output.dir}\coverage.log"
            failonerror="true">
            <assemblies basedir=".">
                <include name="**/${application.base.namespace}*.dll" />
                <exclude name="**/${application.base.namespace}*Tests.dll" />
            </assemblies>
        </ncover>
        <typemockstop />

The problem is still the same, that is we are getting a "TypeMock not enabled" exception in all tests that use TypeMock. Code coverage, however, is produced correctly.

I have tried to run the tests without NCover, and they run fine. I also tried to run them with NCover but without explicitly enabling TypeMock in the script (with the NAnt task) and I still get the same error. Note that TypeMock is linked with 'NCover2.0' from the configuration tool.

What are we doing wrong here?

Thanks in advance,
/Enrico
answered by megakemp (3k points)
0 votes
Enrico hi,

we will need to check the exact syntax here to see why this does not work.
in the meantime. try using the //pm flag of the ncover.

I remember that we had problems making NCover, MSTest and Typemock play along together and using that flag was necessary.

I will get back to you as soon as find a better answer.
answered by lior (13.2k points)
0 votes
Hi Lior,

Thanks for your quick response.
I am setting the profiledProcessModule property of the NCover NAnt task to "VSTestHost.exe", that would be equivalent to specifying the //pm flag from the command line.

Kind regards,
/Enrico
answered by megakemp (3k points)
...