Class TruthFailureSubject


  • public final class TruthFailureSubject
    extends ThrowableSubject
    Subject for AssertionError objects thrown by Truth. TruthFailureSubject contains 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 about(...) call.

    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.