Package com.google.common.truth
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 common supertype for Array subjects, abstracting some common display and error infrastructure.Given the stack frame of a failing assertion, tries to describe what the user passed to
assertThat.An entry that contains a description of how it was created.A value class to represent a frame.This is the type used for type inference.A method invocation.An entry that we know nothing about except for its type.An entry on the stack (or the local-variable table) with a type and sometimes a description of how the value was produced or, as a special case, whether the value is a Truth subject.AnAssertionErrorcomposed of structuredFactinstances and other string messages.Propositions forBigDecimaltyped subjects.Propositions for boolean subjects.Propositions forClasssubjects.ComparableSubject<T extends Comparable>Propositions forComparabletyped subjects.AnAssertionError(usually a JUnitComparisonFailure, but not under GWT) composed of structuredFactinstances and other string messages.Correspondence<A,E> 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.Helper object to store exceptions encountered while executing aCorrespondencemethod.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>Propositions forDoublesubjects.A partially specified check about an approximate relationship to adoublesubject using a tolerance.Supertype of Truth'sAssertionErrorsubclasses that are created from a list ofFactinstances.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.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."Helper class that wraps a collection ofFactinstances to make them easier to build.An opaque, immutable object containing state from the previous calls in the fluent assertion chain.Whether the value of the original subject and the value of the derived subject are "similar enough" that we don't need to display both.The data from a call to either (a) aSubjectconstructor or (b)Subject.check().Defines what to do when a check fails.Propositions forFloatsubjects.A partially specified check about an approximate relationship to afloatsubject using a tolerance.Helper routines related to graph matchings.Helper which implements the Hopcroft–Karp algorithm.Propositions for GuavaOptionalsubjects.Propositions forIntegersubjects.Propositions forIntStreamsubjects.Propositions forIterablesubjects.Whether to output each missing/unexpected item as its ownFactor to group all those items together into a singleFact.A partially specified check in which the actual elements (normally the elements of theIterableunder test) are compared to expected elements using aCorrespondence.Propositions forLongStreamsubjects.Propositions forlongsubjects.Propositions forMapsubjects.MapSubject.MapDifference<K,A, E> Math utilities to be shared by numeric subjects.Propositions forMultimapsubjects.Propositions forMultisetsubjects.A Subject forObject[]and more genericallyT[].Propositions for Java 8OptionalDoublesubjects.Propositions for Java 8OptionalIntsubjects.Propositions for Java 8OptionalLongsubjects.Propositions for Java 8Optionalsubjects.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.Assertions forPathinstances.Extracted routines that need to be swapped in for GWT, to allow for minimal deltas between the GWT and non-GWT version.A GWT-swapped version of test rule interface that does nothing.A Subject forboolean[].A Subject forbyte[].A Subject forchar[].A Subject fordouble[].A partially specified check for doing assertions on the array similar to the assertions supported forIterablesubjects, 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[].A partially specified check for doing assertions on the array similar to the assertions supported forIterablesubjects, 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[].A Subject forlong[].A Subject forshort[].In a fluent assertion chain, exposes the most commonthatmethod, which accepts a value under test and returns aSubject.Utility that cleans stack traces to remove noise from common frameworks.Enum of the package or class-name based categories of stack frames that might be removed or collapsed by the cleaner.Wrapper around aStackTraceElementfor calculating and holding the metadata used to clean the stack trace.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).Propositions forStreamsubjects.Propositions for string subjects.An object that lets you perform checks on the value under test.The result of comparing two objects for equality.Utility methods used inSubjectimplementors.Missing or unexpected values from a collection assertion, with equal objects grouped together and, in some cases, type information added.Propositions forTablesubjects.Propositions forThrowablesubjects.The primary entry point for Truth, a library for fluent test assertions.AnAssertionErrorthat (a) always supports a cause, even under old versions of Android and (b) omits "java.lang.AssertionError:" from the beginning of its toString() representation.The primary entry point for assertions about Java 8 types.Subject forAssertionErrorobjects thrown by Truth.Provides a way to use Truth to perform JUnit "assumptions." An assumption is a check that, if false, aborts (skips) the test.