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

Performance with Initializing<Class>()

1 Answer 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 09 Oct 2012, 08:10 AM
Hello,
we have the following Problem:
We are using the latest version of JustMock. We have a large set of unit- and integrationtests (about 2000 tests). We are running the tests using nunit. Sometimes in our test we have to use real instances of some classes and sometimes mocks of these classes. So to get this work we used the Mock.Initialize<Class>() Method in our test.
In my Example, all tests are green, but when we use the initialization, the runtime of the all test-methods rise from 1.2sec to 25sec. We use a lot of instances in the tests (about 200). The problem is, that the runtime for each testmethod rises from test to test.
In our real test the runtime for one test rises from 30 seconds to  25 minuts. This is an inaccettabile fact.
Is this a known issue for you? Are there any workarounds except not using the Initialize method?

I have included two screenshots from nunit.
Example: Calling the same test-method for 25 times. You can the runtime rising for each method:

(26 tests), [0:25.530] Success JustMockExampleTest (26 tests), [0:25.530] Success PersonManagerTestWithInit (26 tests), [0:25.530] Success _00EditPerson_WhyInitialize_ExpectedBehavior, [0:00.418] Success _01EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.613] Success _02EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.602] Success _03EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.638] Success _04EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.672] Success _05EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.714] Success _06EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.743] Success _07EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.783] Success _08EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.822] Success _09EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.855] Success _10EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.891] Success _11EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.922] Success _12EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.962] Success _13EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:00.994] Success _14EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.029] Success _15EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.061] Success _16EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.100] Success _17EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.139] Success _18EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.167] Success _19EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.206] Success _20EditPerson_Creating_LotsOfPersons_ExpectedBehavior, [0:01.252] Success _21EditPerson_Creating_LotsOfPersonsOnlyArrange_ExpectedBehavior, [0:01.272] Success _22EditPerson_Creating_LotsOfPersonsOnlyArrange_ExpectedBehavior, [0:01.269] Success _23EditPerson_Creating_LotsOfPersonsOnlyArrange_ExpectedBehavior, [0:01.276] Success _24EditPerson_Creating_LotsOfPersonsOnlyArrange_ExpectedBehavior, [0:01.290] Success _25EditPerson_Creating_LotsOfPersonsOnlyArrange_ExpectedBehavior, [0:01.299] Success

Thank you very much.
Christian

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 10 Oct 2012, 10:34 PM
Hi Christian,

Thanks again for contacting us. 

Mock.Initialize is used for marking methods that have the chances of being invoked directly so that it does not raise the OnJITCompilationStarted event. Generally, you can add the initialization inside a static block so that it is not invoked for each test. Moreover, if you know method that is causing or can cause the possible side effect due to the above mentioned event then you can specifically initialize it using Mock.Partial that will make the test run significantly faster.

Kind Regards
Ricky
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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