public final class Fact extends Object implements Serializable
Most Truth users will never interact with this type. It appears in the Truth API only as a
parameter to methods like Subject.failWithActual(Fact, Fact...)
, which are used only by
custom Subject
implementations.
Modifier and Type | Method and Description |
---|---|
static Fact |
fact(String key,
Object value)
Creates a fact with the given key and value, which will be printed in a format like "key:
value." The value is converted to a string by calling
String.valueOf on it. |
static Fact |
simpleFact(String key)
Creates a fact with no value, which will be printed in the format "key" (with no colon or
value).
|
String |
toString()
Returns a simple string representation for the fact.
|
public static Fact fact(String key, @NullableDecl Object value)
String.valueOf
on it.public static Fact simpleFact(String key)
In most cases, prefer key-value facts, which give Truth more flexibility
in how to format the fact for display. simpleFact
is useful primarily for:
isNotEmpty()
would generate the
fact "expected not to be empty"
contains()
sometimes
displays facts like "expected to contain: ..." "but did not" "though it did
contain: ..."
public String toString()
TruthFailureSubject
output, we're moving away from the old-style messages
and onto makeMessage(com.google.common.collect.ImmutableList<java.lang.String>, com.google.common.collect.ImmutableList<com.google.common.truth.Fact>)
, which aligns facts horizontally and indents multiline values.Copyright © 2018. All rights reserved.