Are there any publically available java collections unit tests?

collections, java, unit-testing

Solution

Guava has a set of `TestSuiteBuilders` that, together, produce between a few hundred and a few thousand test cases for a given collection implementation, in the `guava-testlib` component. For example, you might write something like

public static Test suite() {
  return SetTestSuiteBuilder.using(new TestStringSetGenerator() {
      @Override protected Set<String> create(String[] elements) {
         return ImmutableSet.copyOf(elements);
       }
    })
    .named("ImmutableSet");
    .withFeatures(CollectionSize.ANY, CollectionFeature.KNOWN_ORDER,
        CollectionFeature.SERIALIZABLE,
        CollectionFeature.ALLOWS_NULL_QUERIES)
    .createTestSuite();
}

This produces a complete, extremely exhaustive set of test cases for the `Set` implementation.

It's not as thoroughly documented as it could be, but it'll get you a very exhaustive test suite.

Problem

Tests which i can plug-in my implementation of Set and ListIterator specifically.

Original source

Related problems