Package com.google.common.truth
@CheckReturnValue
@NullMarked
package com.google.common.truth
Truth is a library for performing assertions in
tests:
assertThat(notificationText).contains("testuser@google.com");
Truth is owned and maintained by the Guava team. It is used in the majority of the tests in Google’s own codebase.
For more information, see our introduction and other docs.
-
ClassDescriptionA subject for
BigDecimalvalues.A subject forBooleanvalues.A subject forClassvalues.ComparableSubject<T extends Comparable<?>>A subject forComparablevalues.Determines whether an instance of typeAcorresponds in some way to an instance of typeEfor the purposes of a test assertion.A functional interface for a binary predicate, to be used to test whether a pair of objects of typesAandEsatisfy some condition.A functional interface to be used format the diff between a pair of objects of typesAandE.In a fluent assertion chain, exposes one or more "custom"thatmethods, which accept a value under test and return aSubject.CustomSubjectBuilder.Factory<CustomSubjectBuilderT extends CustomSubjectBuilder>A subject forDoublevalues.A partially specified check about an approximate relationship to adoublevalue using a tolerance.ATestRulethat batches up all failures encountered during a test, and reports them all together at the end (similar toErrorCollector).A utility for testing that assertions against a customSubjectfail when they should, plus a utility to assert about parts of the resulting failure messages.ExpectFailure.SimpleSubjectBuilderCallback<S extends Subject, A>A functional interface forexpectFailureAbout()to invoke and capture failures.A functional interface forexpectFailure()to invoke and capture failures.A string key-value pair in a failure message, such as "expected: abc" or "but was: xyz."An opaque, immutable object containing state from the previous calls in the fluent assertion chain.Defines what to do when a check fails.A subject forFloatvalues.A partially specified check about an approximate relationship to afloatvalue using a tolerance.A subject for GuavaOptionalvalues.A subject forIntegervalues.A partially specified check about an approximate relationship to aintactual value using a tolerance.A subject forIntStreamvalues.A subject forIterablevalues.A partially specified check in which the actual elements (normally the elements of theIterableunder test) are compared to expected elements using aCorrespondence.A subject forLongStreamvalues.A subject forLongvalues.A partially specified check about an approximate relationship to alongvalue using a tolerance.A subject forMapvalues.A partially specified check in which the actual values (i.e. the values of theMapunder test) are compared to expected values using aCorrespondence.A subject forMultimapvalues.A partially specified check in which the actual values (i.e. the values of theMultimapunder test) are compared to expected values using aCorrespondence.A subject forMultisetvalues.A subject forObject[]and more genericallyT[].A subject forOptionalDoublevalues.A subject forOptionalIntvalues.A subject forOptionalLongvalues.A subject forOptionalvalues.Returned by calls likeIterableSubject.containsExactly(java.lang.Object...),Orderedlets the caller additionally check that the expected elements were present in the order they were passed to the previous calls.A subject forPathvalues.A subject forboolean[]values.A subject forbyte[]values.A subject forchar[]values.A subject fordouble[]values.A partially specified check for doing assertions on the array similar to the assertions supported forIterablevalues, in which the elements of the array under test are compared to expected elements using either exact or tolerant double equality: seePrimitiveDoubleArraySubject.usingExactEquality()andPrimitiveDoubleArraySubject.usingTolerance(double).A subject forfloat[]values.A partially specified check for doing assertions on the array similar to the assertions supported forIterablevalues, in which the elements of the array under test are compared to expected elements using either exact or tolerant float equality: seePrimitiveFloatArraySubject.usingExactEquality()andPrimitiveFloatArraySubject.usingTolerance(double).A subject forint[]values.A subject forlong[]values.A subject forshort[]values.SimpleSubjectBuilder<SubjectT extends Subject, ActualT>In a fluent assertion chain, exposes the most commonthatmethod, which accepts a value under test and returns aSubject.In a fluent assertion chain, an object with which you can do any of the following: Set an optional message withStandardSubjectBuilder.withMessage(java.lang.String).A subject forStreamvalues.A subject forStringvalues.Offers case-insensitive checks for string values.An object that lets you perform checks on the value under test.Subject.Factory<SubjectT extends Subject, ActualT>A subject forTablevalues.A subject forThrowablevalues.The primary entry point for Truth, a library for fluent test assertions.Deprecated.A subject forAssertionErrorobjects thrown by Truth.Provides a way to use Truth to perform JUnit "assumptions."
Truthclass.