Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #4199
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: What is/are the difference(s) between assertSame and assertEquals in JUnit? |
| Date | 2017-04-28 11:03 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <odvleb$pof$1@dont-email.me> (permalink) |
| References | <g7coe7$hn9$1@news.nems.noaa.gov> <819d27c7-ecb0-4fd2-8b24-ab2040bfd636@googlegroups.com> |
On 4/28/2017 10:04 AM, anvesh.boddupalli@securifi.com wrote:
> I have a similar problem
>
> Genericindex a;
> Genericindex b;
>
> a= datafrommethod();//returns object of Genericindex
> b= datafrommethod();//returns object of Genericindex
>
> b= anothermethod(b);//some object might be overriden
>
> if(notoverridden){
> assertEquals(a,b);}// this fails
>
> can someone explain this?
There's not enough information for a full explanation -- in
particular, we don't know what datafrommethod() does, nor what
anothermethod() does. However, if the assertEquals() reports a
failure, what we *do* know is
1) At least one of `a' and `b' is non-null, because if both
were null assertEquals() would not fail. (It considers two
null references to be "equal.")
2) If `a' is null then `b' is non-null. Similarly, if `b'
is null then `a' is non-null. Either way, `a' and `b' are
unequal: One points to an object, and the other is null.
3) If both `a' and `b' are non-null, then they point to
two objects that are not equal according to the equals() method.
This might be the equals() method of GenericIndex itself, or of
a subclass of GenericIndex (if `a' or `b' points to a subclass
instance), or an equals() method that GenericIndex inherits
from one of its superclasses (perhaps java.lang.Object).
... and that's really all I can discern from what you've
provided. If I knew more about about datafrommethod(), about
anothermethod(), and about GenericIndex and its sub- and
super-classes, I might be able to explain more fully.
--
esosman@comcast-dot-net.invalid
Thirteen hundred sixty-three days to go.
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar
Re: What is/are the difference(s) between assertSame and assertEquals in JUnit? anvesh.boddupalli@securifi.com - 2017-04-28 07:04 -0700 Re: What is/are the difference(s) between assertSame and assertEquals in JUnit? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-04-28 11:03 -0400
csiph-web