Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #4199
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| 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 | Fri, 28 Apr 2017 11:03:34 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 44 |
| Message-ID | <odvleb$pof$1@dont-email.me> (permalink) |
| References | <g7coe7$hn9$1@news.nems.noaa.gov> <819d27c7-ecb0-4fd2-8b24-ab2040bfd636@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Fri, 28 Apr 2017 15:00:27 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="16de2092e9dcbfc968e28d51fea274a7"; logging-data="26383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WoMUH+Bxc1mSvh4s3S7/4" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 |
| In-Reply-To | <819d27c7-ecb0-4fd2-8b24-ab2040bfd636@googlegroups.com> |
| Content-Language | en-US |
| Cancel-Lock | sha1:4tPPmJrCEj5vFxaPueHEHRL59IA= |
| Xref | csiph.com comp.lang.java.help:4199 |
Show key headers only | View raw
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