JUnit tests for Java collections

View: New views
4 Messages — Rating Filter:   Alert me  

JUnit tests for Java collections

by ilango_g :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am interested in knowing if somebody has already written Junit unit tests for Java Collection Classes.
Thanks in advance.


Re: JUnit tests for Java collections

by brettddaniel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



From the way you worded your question, it sounds like you're looking for tests for the java.util.* classes.  Unfortunately, I am unaware of any canonical set of unit tests (though I would find them useful if other list members know of any).  However, the Apache Commons Collections library (http://commons.apache.org/collections/) has an extensive suite of unit tests for many collection classes.  In particular, see the org.apache.commons.collections.collection.AbstractTestCollection class and its subclasses (AbstractTestList, AbstractTestSet, etc.).  You may be able to adapt this suite to test java.util.*.

Alternately, if you are looking for a test suite to test a custom collection class, it is pretty easy to extend the Apache Commons Collections suite.  I have done so in the past for a personal project.

Brett

--- In junit@..., "ilangocal" <ilangocal@...> wrote:
>
> I am interested in knowing if somebody has already written Junit unit tests for Java Collection Classes.
> Thanks in advance.
>



Re: JUnit tests for Java collections

by B. Sai Prasad, M.Phil, SCJP, MCP, MCTS, SSGB, PMP, PMI-SP :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi -

You can use hamcrest asserts in JUnit 4.x to test your collections.

Please visit http://code.google.com/p/hamcrest/wiki/Tutorial,
http://www.jmock.org/javadoc/2.5.1/ for its usage.

Regards
Sai

On 10/25/09, ilangocal <ilangocal@...> wrote:
>
>
>
> I am interested in knowing if somebody has already written Junit unit tests
> for Java Collection Classes.
> Thanks in advance.
>
>
>



--
What am I doing now? Visit  http://twitter.com/saipower


[Non-text portions of this message have been removed]


Re: JUnit tests for Java collections

by MrWiggles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What do you mean by tests for the Java collection classes? If you're
referring to tests that exercise the collections classes, you don't need
them as they are not code you've written and hence should not be tested.
When interacting with 3rd party code you should make the assumption that it
"just works" and test that your code interacts with it correctly

On Sun, Oct 25, 2009 at 3:19 PM, ilangocal <ilangocal@...> wrote:

>
>
> I am interested in knowing if somebody has already written Junit unit tests
> for Java Collection Classes.
> Thanks in advance.
>
>  
>



--
Maybe she awoke to see the roommate's boyfriend swinging from the chandelier
wearing a boar's head.

Something which you, I, and everyone else would call "Tuesday", of course.


[Non-text portions of this message have been removed]