Setup Problems

How do I use with typemock?

Started by pete on 9,860 views

I saw in the release notes that it works with TypeMock, but I'm not sure how to set it up. All my TypeMock tests are failing.
Hi Pete,

Thanks for posting! NCrunch should auto-detect TypeMock and host it in the task environment. Are you able to provide any more information about how the tests are failing? If you're able to submit a bug report after your tests fail, this would be very useful in identifying why it's not working.


Cheers,

Remco
Here's an example failure:

TypeMock.VerifyException :
TypeMock Verification: Call to nCrunch.TestRuntime.TestCoverageEventListener.MarkTestLineStart() Parameter: 1
expected: <(null)>
but was: <2>
at dq.a(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType, Object p1, Object p2, Object p3, Object p4)
at nCrunch.TestRuntime.TestCoverageEventListener.MarkTestLineStart(Int32 componentId, Int32 coverageMarkerIndex, Int32& existingCoverageMarkerIndex, UInt32& existingTickCount)
at TetraData.Common.SQL.DbCommandExecute.ExecuteScriptSplitOnGo(ITDDbConnection conn, String sql) in c:\dev7\source\Shared\Common\DbCommandExecute.cs:line 0
at CommonTests.DbCommandExecuteFixture.ExecuteScriptSplitOnGo() in c:\dev7\source\Shared\Common\CommonTests\DbCommandExecuteFixture.cs:line 37

One thing worth mentioning, this test uses the old style Typemock with RecordExpectataions, not the new Isolate. Does that make a difference to you, or is that all contained within the TypeMock engine?

Thanks,

pete
Yes - NCrunch does have issues with the RecordExpectations syntax. The instrumentation placed by NCrunch is causing TypeMock to make incorrect assessments about your test expectations.

There are two ways you can work around this:

1. Avoid using RecordExpectations - This is the best option but I understand that it may cause a bit of pain

2. Set the 'Instrument assembly' option to 'False' for your test assemblies that are making use of RecordExpectations. You'll lose NCrunch code coverage on these assemblies, but the tests should run OK. The more important test coverage would be on your code under test anyway, so this may work for you. You could take this approach a little further by moving the tests with RecordExpectations into their own assembly so that you can still have code coverage over your other tests.


Cheers,

Remco

Post a reply

Log in to reply.