|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.common.testing.NullPointerTester
@Beta public final class NullPointerTester
A test utility that verifies that your methods throw NullPointerException
or UnsupportedOperationException
whenever any
of their parameters are null. To use it, you must first provide valid default
values for the parameter types used by the class.
Constructor Summary | |
---|---|
NullPointerTester()
|
Method Summary | ||
---|---|---|
NullPointerTester |
ignore(Member member)
Ignore a member (constructor or method) in testAllXxx methods. |
|
|
setDefault(Class<T> type,
T value)
Sets a default value that can be used for any parameter of type type . |
|
void |
testAllPublicConstructors(Class<?> c)
Runs testConstructor(java.lang.reflect.Constructor>) on every public constructor in class c . |
|
void |
testAllPublicInstanceMethods(Object instance)
Runs testMethod(java.lang.Object, java.lang.reflect.Method) on every public instance method of
instance . |
|
void |
testAllPublicStaticMethods(Class<?> c)
Runs testMethod(java.lang.Object, java.lang.reflect.Method) on every public static method in class
c . |
|
void |
testConstructor(Constructor<?> ctor)
Verifies that ctor produces a NullPointerException or
UnsupportedOperationException whenever any of its
non-Nullable parameters are null. |
|
void |
testConstructorParameter(Constructor<?> ctor,
int paramIndex)
Verifies that ctor produces a NullPointerException or
UnsupportedOperationException when the parameter in position paramIndex is null. |
|
void |
testMethod(Object instance,
Method method)
Verifies that method produces a NullPointerException
or UnsupportedOperationException whenever any of its
non-Nullable parameters are null. |
|
void |
testMethodParameter(Object instance,
Method method,
int paramIndex)
Verifies that method produces a NullPointerException or
UnsupportedOperationException when the parameter in position paramIndex is null. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NullPointerTester()
Method Detail |
---|
public <T> NullPointerTester setDefault(Class<T> type, T value)
type
. Returns this object.
public NullPointerTester ignore(Member member)
public void testAllPublicConstructors(Class<?> c) throws Exception
testConstructor(java.lang.reflect.Constructor>)
on every public constructor in class c
.
Exception
public void testAllPublicStaticMethods(Class<?> c) throws Exception
testMethod(java.lang.Object, java.lang.reflect.Method)
on every public static method in class
c
.
Exception
public void testAllPublicInstanceMethods(Object instance) throws Exception
testMethod(java.lang.Object, java.lang.reflect.Method)
on every public instance method of
instance
.
Exception
public void testMethod(Object instance, Method method) throws Exception
method
produces a NullPointerException
or UnsupportedOperationException
whenever any of its
non-Nullable
parameters are null.
instance
- the instance to invoke method
on, or null if
method
is static
Exception
public void testConstructor(Constructor<?> ctor) throws Exception
ctor
produces a NullPointerException
or
UnsupportedOperationException
whenever any of its
non-Nullable
parameters are null.
Exception
public void testMethodParameter(Object instance, Method method, int paramIndex) throws Exception
method
produces a NullPointerException
or
UnsupportedOperationException
when the parameter in position paramIndex
is null. If this parameter is marked Nullable
, this
method does nothing.
instance
- the instance to invoke method
on, or null if
method
is static
Exception
public void testConstructorParameter(Constructor<?> ctor, int paramIndex) throws Exception
ctor
produces a NullPointerException
or
UnsupportedOperationException
when the parameter in position paramIndex
is null. If this parameter is marked Nullable
, this
method does nothing.
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |