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

6 posts, 0 answers
  1. Ran
    Ran avatar
    3 posts
    Member since:
    Aug 2011

    Posted 14 Aug 2011 Link to this post

    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?

  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 15 Aug 2011 Link to this post

    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 >>

  3. DevCraft R3 2016 release webinar banner
  4. Ran
    Ran avatar
    3 posts
    Member since:
    Aug 2011

    Posted 15 Aug 2011 Link to this post

    Strange.

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

    Is there anything i should else I should check?

    Ran.
  5. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 15 Aug 2011 Link to this post

    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 >>

  6. Ran
    Ran avatar
    3 posts
    Member since:
    Aug 2011

    Posted 15 Aug 2011 Link to this post

    Thanks for the quick response. I'd try to reproduce this and send you the code.

    -Ran.
  7. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 18 Aug 2011 Link to this post

    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 >>

Back to Top
DevCraft R3 2016 release webinar banner