commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil O'Toole <neiloto...@yahoo.com>
Subject [collections] [patch] TestList and TestCollection
Date Sat, 26 Apr 2003 06:13:25 GMT
And of course, here come the actual patch files a little later...

- Neil

>>>>>>>>>>>
A small bug from the glamourous side of open-source (down in the bowels
of the test suite). TestList#BulkTestSubList was missing the
isSetSupported() operation. This is added in the patch, as well as a
few minor changes to the test output in TestList.java and
TestCollection.java to make testing a bit easier, e.g. 

 assertTrue("Empty collection shouldn'y contain element",
                       !collection.contains(elements[i]));

becomes

assertTrue("Empty collection shouldn't contain element[" + i + "]",
                       !collection.contains(elements[i]));

As a general note when writing test code, there is really no gain from
writing succinct statements or trying to save on assignments, and it
does make life harder for people using the test suites. So, instead of
writing:

    assertTrue( myObject.getSomething().equals( somethingElse ))

we're better off doing

Something s = myObject.getSomething();
assertTrue( s.equals( somethingElse ));

As that sort of code generally makes it much easier to debug (even with
all these new-fangled fancy debuggers).

- Neil

Mime
View raw message