MikeFHay
MikeFHay

Reputation: 9050

Where can I find unit tests for Java standard library classes?

I'm planning on subclassing certain classes in the Java standard library (my immediate use case is extending java.io.File), and I'd like to be able to test that I haven't broken any contracts of the class. I thought there must be some unit tests for the Java standard library classes available under a permissive licence that I can use, however I can't seem to find any.

This question was asked 4 years ago, but no good answer was given.

Upvotes: 3

Views: 641

Answers (2)

MikeFHay
MikeFHay

Reputation: 9050

It turns out extending java.io.File was a bad idea, so never mind that.

For the standard collections, guava-tests has some excellent interface contract tests. For example, https://github.com/google/guava/blob/master/guava-tests/test/com/google/common/collect/CompactHashSetTest.java uses SetTestSuiteBuilder to test that CompactHashSet complies with Set contracts.

Upvotes: 2

avidD
avidD

Reputation: 451

You may want to have a look at this: http://openjdk.java.net/groups/quality/collaborate/testing.html

Upvotes: 0

Related Questions