Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 478
MikeFHay Avatar asked Sep 15 '25 15:09

MikeFHay


1 Answers

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.

like image 187
MikeFHay Avatar answered Sep 18 '25 06:09

MikeFHay