Is there a testsuite for Java custom collections implementation?

collections, java, unit-testing

Solution

Use the Guava `SetTestSuiteBuilder`.

https://github.com/google/guava/blob/master/guava-testlib/src/com/google/common/collect/testing/SetTestSuiteBuilder.java

Examples:

https://github.com/google/guava/blob/master/guava-testlib/src/com/google/common/collect/testing/TestsForSetsInJavaUtil.java

It is released as part of "guava-testlib" in maven central.

Problem

Out of curiosity, I wrote an own simple implementation of `Set` for a special case (where the set of all possible entries is fixed, but it's no `enum`). It was actually quite easy, but obviously, my implementation is unusable without a lot of tests (and maybe even then, but that's another topic; it was mainly an exercise). So is there any testsuite available I could use for unit-testing it?

Original source