public final class TruthFailureSubject extends ThrowableSubject
AssertionErrorobjects thrown by Truth.
TruthFailureSubjectcontains methods for asserting about the individual "facts" of those failures. This allows tests to avoid asserting about the same fact more often than necessary, including avoiding asserting about facts that are set by other subjects that the main subject delegates to. This keeps tests shorter and less fragile.
To create an instance, call
ExpectFailure.assertThat(java.lang.AssertionError). Or, if you're using a custom
message or failure strategy, pass
truthFailures() to your
This class accepts any
AssertionError value, but it will throw an exception if a
caller tries to access the facts of an error that wasn't produced by Truth.
|Modifier and Type||Method and Description|
Returns a subject for the list of fact keys.
Returns a subject for the value with the given name.
Returns a subject for the value of the
Factory for creating
actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString
public static Subject.Factory<TruthFailureSubject,AssertionError> truthFailures()
TruthFailureSubjectinstances. Most users will just use
public IterableSubject factKeys()
public StringSubject factValue(String key)
The value is always a string, the
String.valueOf representation of the value passed
The value is never null:
factValuethrows an exception. To test for such facts, use
.contains(...)or a similar method.
factValueconsiders them have a string value, the string "null."
If the failure under test contains more than one fact with the given key, this method will
fail the test. To assert about such a failure, use the
other overload of
Copyright © 2020. All rights reserved.