Loading ...
Sorry, an error occurred while loading the content.

Re: [junit] assertEquals is not calling my custom equals method on a template class

Expand Messages
  • David Saff
    First thing to do is to make double-sure that your equals method overrides Object.equals(Object). I ve several times ended up writing a method that
    Message 1 of 3 , Apr 21 3:57 AM
    View Source
    • 0 Attachment
      First thing to do is to make double-sure that your equals method
      overrides Object.equals(Object). I've several times ended up writing
      a method that _overloads_ equals, like MyFoo.equals(MyFoo), and that
      will not be picked up. It needs to be MyFoo.equals(Object).

      Hope that helps,

      David Saff

      On Thu, Apr 21, 2011 at 4:55 AM, stefanroels <stefan.roels@...> wrote:
      > I have a template class and I have written an equals method to ensure that the proper logic is used when testing equality. However assertEquals never calls this method (I have put a Sytem.out.println call in my equals, but nothing is printed).
      >
      > Is there anything special I would have to do to make assertEquals call my method?
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
    • stefanroels
      That was exactly the problem. No I have another (smaller) problem. Thanks, Stefan
      Message 2 of 3 , Apr 21 4:55 AM
      View Source
      • 0 Attachment
        That was exactly the problem.

        No I have another (smaller) problem.

        Thanks,

        Stefan

        --- In junit@yahoogroups.com, David Saff <david@...> wrote:
        >
        > First thing to do is to make double-sure that your equals method
        > overrides Object.equals(Object). I've several times ended up writing
        > a method that _overloads_ equals, like MyFoo.equals(MyFoo), and that
        > will not be picked up. It needs to be MyFoo.equals(Object).
        >
        > Hope that helps,
        >
        > David Saff
        >
        > On Thu, Apr 21, 2011 at 4:55 AM, stefanroels <stefan.roels@...> wrote:
        > > I have a template class and I have written an equals method to ensure that the proper logic is used when testing equality. However assertEquals never calls this method (I have put a Sytem.out.println call in my equals, but nothing is printed).
        > >
        > > Is there anything special I would have to do to make assertEquals call my method?
        > >
        > >
        > >
        > > ------------------------------------
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.