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'm trying to get my tests integrated our build process and am running into some problems. On my local machine through both vsnet, and the Nant buildfile the tests pass(without having to use typemockstart/end).

On the build server it's a different story. At first of the 401 tests, 291 failed. Mostly with the message indicating that TypeMock wasn't enabled. So I went ahead and added "typemockstart" and "typemockstop" tasks in the proper locations, with a target of 2.0. This brought the fail count down to 156, a lot of them are TypeInitializationExceptions, with some verification failures and such, but it all seems to point to something wrong with the way TypeMock is working.

So TypeMock is sort of working, and I don't think it's something wrong specifically with TypeMock, just that something is different between the two environments. I have no idea what it could be though. TypeMock is being run through NCover, but that is also the same version as my local machine. I don't know if it makes a difference, but I should also note that even though my code is .net v3.5 if I try to set the target to 3.5 NCover just throws an error that doesn't give any information.

Any thoughts?

Thanks,
Steve
asked by vertebrate (1.8k points)

5 Answers

0 votes
Hi Vertebrate,

This indeed seems to be an environment set up issue. Would it be possible for you to post your build script (or the relevant excerpts: Typemock tasks and the call to NCover/NUnit) here? You can also see the relevant help file for integrating NAnt and Typemock here: https://www.typemock.com/Docs/UserGuide/ ... Build.html.

Also, you seem to have stumbled onto a bug with the target attribute of the TypeMockStart task; these seem to be limited to 1.1 and 2.0 for historical reasons, and 3.5 doesn't really have an affect. We'll take care of that in a future release.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
The buildfile is pretty extensive, but here's the relevant part.

          <typemockstart target="2.0" link="NCover2.0" loglevel="2"/>
          <ncover program="${ncover.console.path}"
            commandLineExe="${nunit.console.path}"
            commandLineArgs="${test.assembly}.test.dll /xml=&quot;${test.output.dir}${test.assembly}.test.xml&quot;"            
            workingDirectory="${build.unit.test.dir}${test.path}inDebug"
            assemblyList="${test.assembly}"
            coverageFile="${coverage.output.dir}${test.assembly}.coverage.xml"
            logFile="${coverage.output.dir}${test.assembly}.log"
            registerProfiler="false"
            fileExclusionPatterns=".*schema.cs"
          />
          <typemockstop/>


Here's an example of one of the more common errors, and the stack trace:

An unexpected exception type was thrown Expected: System.Exception but was: System.TypeInitializationException : The type initializer for 'CA.Logging.Logger' threw an exception.
at CA.Logging.Logger.Error(String message, Exception e, Object[] args)
at Apollo.AIM.DCF.DcfService.GetCapQuestions(String jobCode, String costCode) in c:ccnet_buildcap.6.x-build
eleaseuildsrclibDCF.testDcfService.cs:line 53
at Apollo.AIM.DCF.test.DcfService_GetCapQuestions_InvalidCostCode.ShouldThrowAnException() in c:ccnet_buildcap.6.x-build
eleaseuildsrc	estunitlibDCF.testDcfService_Test.cs:line 93
at TypeMock.VerifyMocksAttribute.Execute()
at TypeMock.DecoratorAttribute.CallDecoratedMethod()
at TypeMock.ClearMocksAttribute.Execute()
at TypeMock.MethodDecorator.e()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at DCF.test.DcfService_GetCapQuestions_InvalidCostCode.ShouldThrowAnException() in c:ccnet_buildcap.6.x-build
eleaseuildsrc	estunitlibDCF.testDcfService_Test.cs:line 85
answered by vertebrate (1.8k points)
0 votes
I just tried running the tests through vsnet with testrunner.net on the build server and everything failed just like in the build process. So this doesn't even appear to be an issue with ncover(yet). Could it be that I'm currently running an eval license of TypeMock while I wait for purchasing to get an official license? I thought the eval license had the same feautures, but maybe I'm wrong?

Thanks,
Steve
answered by vertebrate (1.8k points)
0 votes
As I expected it was environmental in nature. A config value was missing. The errors were very strange though and made it seem more like TypeMock was to blame, which it wasn't.
answered by vertebrate (1.8k points)
0 votes
Hi Steve,

I'm glad that you solved this.

The reason you see Isolator traces on the stack, is because of the ClearMocks attribute that wraps the test, and actually runs it. So I understand why you would suspect Isolator.

Was the missing configuration setting application-specific or more general? The reason I'm asking is that if it is not specific we might be either be able to give better messages or set it ourselves.

Thanks,
answered by gilz (14.5k points)
...