Package com.google.common.truth
Class ActualValueInference
java.lang.Object
com.google.common.truth.ActualValueInference
Given the stack frame of a failing assertion, tries to describe what the user passed to
assertThat.
For example, suppose that the test contains:
assertThat(logService.fetchLogMessages(startDate, endDate))
.containsExactly(message1, message2)
.inOrder();
If either containsExactly or inOrder fails, ActualValueInference reports
(if the rest of the test method is simple enough to analyze easily) that the user passed
fetchLogMessages(...). This allows us to produce a failure message like:
value of : fetchLogMessages(...) missing (1): message1 ...
ActualValueInference accomplishes this by examining the bytecode of the test. Naturally,
this is all best-effort.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classAn entry that contains a description of how it was created.(package private) static classA value class to represent a frame.private static final classprivate static final class(package private) static classThis is the type used for type inference.(package private) static classA method invocation.(package private) static @interface(package private) static classAn entry that we know nothing about except for its type.(package private) static classAn entry on the stack (or the local-variable table) with a type and sometimes a description of how the value was produced or, as a special case, whether the value is a Truth subject.(package private) static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcloseQuietly(InputStream stream) (package private) static StringdescribeActualValue(String className, String methodName, int lineNumber) CallPlatform.inferDescription()rather than calling this directly.private static ActualValueInference.StackEntrydescribed(ActualValueInference.InferredType type, String description) private static booleanprivate static booleanisSet(int flags, int bitmask) Returnstrueiff all bits inbitmaskare set inflags.private static booleanisStatic(int access) private static booleanisThatOrAssertThat(String owner, String name) private static ActualValueInference.StackEntryprivate static ActualValueInference.StackEntry
-
Field Details
-
BORING_NAMES
-
PRIMITIVE_WRAPPERS
-
-
Constructor Details
-
ActualValueInference
private ActualValueInference()
-
-
Method Details
-
describeActualValue
CallPlatform.inferDescription()rather than calling this directly. -
opaque
-
described
private static ActualValueInference.StackEntry described(ActualValueInference.InferredType type, String description) -
subjectFor
private static ActualValueInference.StackEntry subjectFor(ActualValueInference.InferredType type, ActualValueInference.StackEntry actual) -
isThatOrAssertThat
-
isBoxing
-
isStatic
private static boolean isStatic(int access) -
isSet
private static boolean isSet(int flags, int bitmask) Returnstrueiff all bits inbitmaskare set inflags. Trivially returnstrueifbitmaskis 0. -
closeQuietly
-