Class NullPointerTester


  • @GwtIncompatible
    public final class NullPointerTester
    extends Object
    A test utility that verifies that your methods and constructors throw NullPointerException or UnsupportedOperationException whenever null is passed to a parameter whose declaration or type isn't annotated with an annotation with the simple name Nullable, CheckForNull, NullableType, or NullableDecl.

    The tested methods and constructors are invoked -- each time with one parameter being null and the rest not null -- and the test fails if no expected exception is thrown. NullPointerTester uses best effort to pick non-null default values for many common JDK and Guava types, and also for interfaces and public classes that have public parameter-less constructors. When the non-null default value for a particular parameter type cannot be provided by NullPointerTester, the caller can provide a custom non-null default value for the parameter type via setDefault(java.lang.Class<T>, T).

    Since:
    10.0
    Author:
    Kevin Bourrillion