This is a migrated thread and some comments may be shown as answers.

Clearing Mock objects between tests ?

3 Answers 122 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 09 Sep 2011, 05:37 PM
Hello,

I just encounter a problem when I run multiple tests. Tests run successfully when run indiviually but fail when run in batch.

I am re-mocking the same objects in each tests and I noticed that one of the created mock is using the same proxy key as a previous test !

Do I have to "clear" something between each test ? How ?

Thanks,

Michel

3 Answers, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 13 Sep 2011, 10:17 AM
Hi Michel,

Thanks again for sending the issue. In general cases proxy is cached for similar types but that should not be an issue since the instances are different.

However you if you are doing tests that uses profiler (static, final, etc.), I would recommend you to take a look at this post:
http://www.telerik.com/community/forums/justmock/general-discussions/mocks-failing-to-work-correctly-in-large-test-runs.aspx

Hope that solves your problem.


Kind Regards,
Mehfuz
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Michel
Top achievements
Rank 1
answered on 13 Sep 2011, 03:18 PM
Hello and thank you for the sugestion.

Unfortunately, I had already tried what is proposed but it did not solve the problem.

I am testing the delete of an object in the first test and the delete of a child of the item in the second.

I am not using static classes. I use Mock.Create on all used classes in every test and added .MustBeCalled on the target of the Assert.

The MustBeCalled is not catched by JustMock in the second test when I run both tests together.

Obviously both tests are successful when ran separately...

Is there a way to reset the cached proxy before each test ?

Thanks,

Michel

0
Ricky
Telerik team
answered on 14 Sep 2011, 04:18 PM
Hi Michel,

Thanks again for the reply. This could be the issue with mocking similar methods in nested type. If you can send me a sample demonstrating how the two tests look like then i can try reproducing it in my local machine and send you a possible fix if required.

Kind Regards,
Mehfuz
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Michel
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Michel
Top achievements
Rank 1
Share this question
or