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

JustMock does not play nicely with TestDriven.Net when trying to mock static function

5 Answers 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ran
Top achievements
Rank 1
Ran asked on 14 Aug 2011, 07:39 AM
Hi,

When trying to run tests with TestDriven.Net i get the following exception:

 An error occured executing PopulateHolidays method. ---> Telerik.JustMock.MockException: Exception has been thrown by the target of an invocation.
at .ƒ.( expecation, Object[] userArgs)
at .ƒ.–( invocation)
at ..( invocation)
at ..( invocation)
at ..Intercept(MockInvocation invocation)
at Telerik.JustMock.Weaver.Interceptors.WeaverInterceptor.€(IInvocation invocation)
at PersistenceManager_Interceptor_63dc8f881d054338ad4e199360304e8a.Intercept(PersistenceManager , Boolean& )
 at PersistenceManager.GetCalendarData()

Though when running it with MSTest runner the breakpoint stops correctly on my function.

The code of the test is something like this:
Mock.Arrange(() => PersistenceManager.GetCalendarData()).Returns(() => myDataSet());

Where GetCalendarData is the static method being mocked.

Any idea why this is happening?

5 Answers, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 15 Aug 2011, 10:03 AM
Hi Ran,
Thanks again for sending the issue.

However JustMock officially supports the TestDriven.NET-3.0.2749 RTM build. In case you are using the latest beta which is (3.0.2759), i would recommend you to go with the RTM.

Hope that solves your issue.

Kind Regards,
Mehfuz
the Telerik team

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

0
Ran
Top achievements
Rank 1
answered on 15 Aug 2011, 10:09 AM
Strange.

The testdriven.net version I have is TestDriven.NET-3.0.2749

Is there anything i should else I should check?

Ran.
0
Ricky
Telerik team
answered on 15 Aug 2011, 11:25 AM
Hi Ran,

Thanks again for the quick response.

Looking into the stack trace above, i can see that it crashes during invocation of "PopulateHolidays" method. Will it be possible to provide me the class / method structure that you are trying to mock so that i can test it in my development machine? This will help me address the issue correctly.


Kind Regards
Mehfuz
the Telerik team

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

0
Ran
Top achievements
Rank 1
answered on 15 Aug 2011, 12:12 PM
Thanks for the quick response. I'd try to reproduce this and send you the code.

-Ran.
0
Ricky
Telerik team
answered on 18 Aug 2011, 01:25 PM
Hi Ran,

Hope that you are doing well. While you are preparing the sample I further found that there are some glitches in setting up static method in TestInitialize. Please let me know if your issue is the same then we could prepare a build for you.


Kind regards,
Mehfuz
the Telerik team

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

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