Class FailureMetadata

java.lang.Object
com.google.common.truth.FailureMetadata

public final class FailureMetadata extends Object
An opaque, immutable object containing state from the previous calls in the fluent assertion chain. It appears primarily as a parameter to Subject constructors (and Subject.Factory methods), which should pass it to the superclass constructor and not otherwise use or store it. In particular, users should not attempt to call Subject constructors or Subject.Factory methods directly. Instead, they should use the appropriate factory method:
  • If you're writing a test: Truth.assertAbout(Subject.Factory).that(...)
  • If you're creating a derived subject from within another subject: check(...).about(...).that(...)
  • If you're testing your subject to verify that assertions fail when they should: ExpectFailure

(One exception: Implementations of CustomSubjectBuilder do directly call constructors, using their CustomSubjectBuilder.metadata() method to get an instance to pass to the constructor.)