Clearing Mock objects between tests ?

4 posts, 0 answers
  1. Michel
    Michel avatar
    39 posts
    Member since:
    Jul 2011

    Posted 09 Sep 2011 Link to this post

    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
  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 13 Sep 2011 Link to this post

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

  3. DevCraft R3 2016 release webinar banner
  4. Michel
    Michel avatar
    39 posts
    Member since:
    Jul 2011

    Posted 13 Sep 2011 Link to this post

    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

  5. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 14 Sep 2011 Link to this post

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

Back to Top