Problem passing objects as method parameters

Help
2004-06-10
2013-03-22
  • Juan M. Cervera

    Juan M. Cervera - 2004-06-10

    I am very interested in using the software in my test dreiven development.
    I am still learning, using David Astel's book on the subject.
    My problem is when I try to specified an object, like an ArrayList, as the expected parameter of a method.
    The parameter passed to the mock will never be the same as the expected. How can I make this?
    If you want I can send you a little demo problem where you can see what I say

    Thank you very much
    Juan M. Cervera

     
    • Antonio Ganci

      Antonio Ganci - 2004-07-21

      I have the same problem.
      The only workaround I found is to use the SetDefault... instead of SetVoidCallable, SetReturnValue.
      I guess the expected behavior is to check that the objects passed as method parameters are equivalent and not the same instance.
      Antonio Ganci.

       
    • Jon Skeet

      Jon Skeet - 2005-04-11

      Absolutely - it's all a case of providing an appropriate matcher, basically.

      One thing I'm currently considering is whether it would be useful to have a matcher which (when in "record" mode) treated null as "something may be passed as this parameter, but don't worry about what it is" which would allow the checking of some parameters but not others. It shouldn't be too hard to write, and could be quite useful.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks