Class ClassSanityTester


  • @Beta
    @GwtIncompatible
    public final class ClassSanityTester
    extends java.lang.Object
    Tester that runs automated sanity tests for any given class. A typical use case is to test static factory classes like:
     interface Book {...}
     public class Books {
       public static Book hardcover(String title) {...}
       public static Book paperback(String title) {...}
     }
     

    And all the created Book instances can be tested with:

     new ClassSanityTester()
         .forAllPublicStaticMethods(Books.class)
         .thatReturn(Book.class)
         .testEquals(); // or testNulls(), testSerializable() etc.
     
    Since:
    14.0