Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!n6g2000vbg.googlegroups.com!not-for-mail From: Henk van Voorthuijsen Newsgroups: comp.lang.java.programmer Subject: Re: Question re testing constructor Date: Wed, 7 Dec 2011 00:33:26 -0800 (PST) Organization: http://groups.google.com Lines: 21 Message-ID: References: NNTP-Posting-Host: 62.177.210.148 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1323246806 25090 127.0.0.1 (7 Dec 2011 08:33:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 7 Dec 2011 08:33:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n6g2000vbg.googlegroups.com; posting-host=62.177.210.148; posting-account=DLluPQoAAADpLqA-CJJnTqb8oHjtnsVZ User-Agent: G2/1.0 X-HTTP-Via: 1.1 PI-PROXY-01 X-Google-Web-Client: true X-Google-Header-Order: VCRUHALSNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10581 On Dec 6, 4:14=A0pm, Novice wrote: > > If that is right, then it seems that this should test the existence of th= e > object well enough: > > =A0 =A0 =A0 =A0 Set testValues =3D new HashSet(); > =A0 =A0 =A0 =A0 testValues.add("FF0000"); > =A0 =A0 =A0 =A0 testValues.add("66CC99"); > > =A0 =A0 =A0 =A0 for (String key : testValues) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 HexColor hexColor =3D new HexColor(key); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (hexColor =3D=3D null) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 assertTrue("The HexColor = has been created for input value, > " + key + ", but has been found to be null.", false); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } To assert an objects existence, use assertNotNull().