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

Mock.Assert and Running All Tests In Solution

2 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel Eggers PO 4900000041
Top achievements
Rank 1
Daniel Eggers PO 4900000041 asked on 21 Jun 2011, 02:43 PM
Hi everyone.

I'm having a weird problem with the the JustMock.Assert() method and "Running All Tests" in the solution.

I wrote a solution having < 50 unit tests. In these tests, I'm using the Mock.Assert(), and the .OccursOnce() quite often. Now if I run all these tests at once using the "Run All Tests in Solution" Button some of these fail. But when I run the failing tests once again, they pass.
This means, that I always have to run the unit test twice to get my solution green.

It seems, that this problem appears, when Mocking the same objects in different test cases.

One sample exception of such test would be: 
Test method [methodname] threw exception: 
Telerik.JustMock.MockAssertionException: Expected SAPtoADZipper.Zip(List`1) call on the mock should be once, but it was called 0 time(s).

I'm using Just Mock version 2011.1.315.0, and Microsoft.VisualStudio.TestTools.UnitTesting in Visual Studio 2010 with C# in the 3.5 .net Framework.

Does anyone have a hint for me, how to resolve this?
Maybe there's a way to mark the tests to run in an isolated Thread or something.

Thanks!


2 Answers, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 23 Jun 2011, 08:42 AM
Hi Rainer,

Thanks again for sending the issue. However, can you check if SAPtoADZipper.Zip(List`1) executes the mock(setup) if you run the test method in a group. You can use the "Debug all tests" and put a break-point in the particular method to investigate.

It could also be possible that the method is already invoked in some other test method; in that case you might like to check the following post:

http://www.telerik.com/community/forums/justmock/general-discussions/mocks-failing-to-work-correctly-in-large-test-runs.aspx

Kind Regards,
Ricky
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel Eggers PO 4900000041
Top achievements
Rank 1
answered on 27 Jun 2011, 12:03 PM
Hi Ricky.

thank you for your tip. After adding Mock.Initialize<T>(); into the TestInitialize() method, all the tests go green in a single test run.

Thank you.
Tags
General Discussions
Asked by
Daniel Eggers PO 4900000041
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Daniel Eggers PO 4900000041
Top achievements
Rank 1
Share this question
or