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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I am having some problems with my tests (using Nant/TMockrunner 3.0.3.0). First, I have quite a few legacy tests that don't use TypeMock. I would rather not change these.

On other tests I am using TypeMock to mock some static methods of objects. In the older tests, these are static methods of real constructed objects and in the new tests they are mocked objects.

I am having trouble telling the MockManager to stop mocking these objects. In your examples, you typically call MockManager.Init() in the set up and then MockManager.Verify() in the tear down. If I understand correctly Verify() does not disactivate the Mocking of objects, Init() resets the mocks. I have tried calling MockManager.Init() in the tear down, but something seems to be breaking because I am getting null pointer exceptions when on tests when I am not useing mocked objects (but where other tests in the same build use TypeMock) When I disactivbate my tests that use TypeMock the other tests all pass.

What is the best (or the surest) way to dispose or otherwise disactivate all object mocking (at the end of a test)?

Thanks in advance for any help.

d.

ps. I don't think this is a bug, I think it is just a product of the rather complex build process that we are running.
asked by sellingerd (5.7k points)

2 Answers

0 votes
Hi,
There are some issues with TypeMocked objects and regular ones running together when mocking static constructors.
When these classes have been typemocked need to run in an unmocked mode the static constructor is not called.

We are solving these problems in the coming version of TypeMock.NET.
There we will have a MockManager.ClearUp() methid and the framework will automatically call static constructors when needed.

In any case calling Init() should work except in the case mentioned above. If this is not the case (i.e. not static constructor or initialization of static fields) it is something else that we need to solve, so please send the error you are recieving.

If yuo want to test the new version, please tell us and I will put you on our beta list.
answered by scott (32k points)
0 votes
Thanks for your speedy response. In fact we were just snooping around the same issue and we found that we were mocking a static constructor when we didn't need to be, so we changed the way we set up the mock and it corrected our problem.

thanks again.

d.
answered by sellingerd (5.7k points)
...