Package com.google.common.testing
Class ClassSanityTester.FactoryMethodReturnValueTester
java.lang.Object
com.google.common.testing.ClassSanityTester.FactoryMethodReturnValueTester
- Enclosing class:
ClassSanityTester
Runs sanity tests against return values of static factory methods declared by a class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class
<?> private final ImmutableList
<Invokable<?, ?>> private final String
private Class
<?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FactoryMethodReturnValueTester
(Class<?> declaringClass, ImmutableList<Invokable<?, ?>> factories, String factoryMethodsDescription) -
Method Summary
Modifier and TypeMethodDescriptionprivate ImmutableList
<Invokable<?, ?>> TestsObject.equals(java.lang.Object)
andObject.hashCode()
against the return values of the static methods, by asserting that when equal parameters are passed to the same static method, the return value should also be equal; and vice versa.Runs equals and serialization test on the return values.Tests null checks against the instance methods of the return values, if any.Runs serialization test on the return values of the static methods.thatReturn
(Class<?> returnType) Specifies that only the methods that are declared to returnreturnType
or its subtype are tested.
-
Field Details
-
packagesToTest
-
declaringClass
-
factories
-
factoryMethodsDescription
-
returnTypeToTest
-
-
Constructor Details
-
FactoryMethodReturnValueTester
private FactoryMethodReturnValueTester(Class<?> declaringClass, ImmutableList<Invokable<?, ?>> factories, String factoryMethodsDescription)
-
-
Method Details
-
thatReturn
Specifies that only the methods that are declared to returnreturnType
or its subtype are tested.- Returns:
- this tester object
-
testNulls
Tests null checks against the instance methods of the return values, if any.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
Exception
-
testEquals
TestsObject.equals(java.lang.Object)
andObject.hashCode()
against the return values of the static methods, by asserting that when equal parameters are passed to the same static method, the return value should also be equal; and vice versa.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
Exception
-
testSerializable
Runs serialization test on the return values of the static methods.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
Exception
-
testEqualsAndSerializable
public ClassSanityTester.FactoryMethodReturnValueTester testEqualsAndSerializable() throws ExceptionRuns equals and serialization test on the return values.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
Exception
-
getFactoriesToTest
-