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 class
An entry that contains a description of how it was created.(package private) static class
A value class to represent a frame.private static final class
private static final class
(package private) static class
This is the type used for type inference.(package private) static class
A method invocation.(package private) static @interface
(package private) static class
An entry that we know nothing about except for its type.(package private) static class
An 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 void
closeQuietly
(InputStream stream) (package private) static String
describeActualValue
(String className, String methodName, int lineNumber) CallPlatform.inferDescription()
rather than calling this directly.private static ActualValueInference.StackEntry
described
(ActualValueInference.InferredType type, String description) private static boolean
private static boolean
isSet
(int flags, int bitmask) Returnstrue
iff all bits inbitmask
are set inflags
.private static boolean
isStatic
(int access) private static boolean
isThatOrAssertThat
(String owner, String name) private static ActualValueInference.StackEntry
private 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) Returnstrue
iff all bits inbitmask
are set inflags
. Trivially returnstrue
ifbitmask
is 0. -
closeQuietly
-