-
Classes Class Description com.google.common.truth.Truth8 Instead of this class's methods, use the identical methods declared in the mainTruth
class. In most cases, you can migrate your whole project mechanically:git grep -l Truth8 | xargs perl -pi -e 's/\bTruth8\b/Truth/g;'
Migration is important if you static importassertThat
: If you do not migrate, such static imports will become ambiguous in Truth 1.4.2, breaking your build.
-
Methods Method Description com.google.common.truth.Correspondence.equals(Object) Object.equals(Object)
is not supported. If you meant to compare objects using thisCorrespondence
, useCorrespondence.compare(A, E)
.com.google.common.truth.Correspondence.hashCode() Object.hashCode()
is not supported.com.google.common.truth.DoubleSubject.isEquivalentAccordingToCompareTo(Double) UseDoubleSubject.isWithin(double)
orDoubleSubject.isEqualTo(java.lang.Object)
instead (see documentation for advice).com.google.common.truth.DoubleSubject.TolerantDoubleComparison.equals(Object) Object.equals(Object)
is not supported on TolerantDoubleComparison. If you meant to compare doubles, useDoubleSubject.TolerantDoubleComparison.of(double)
instead.com.google.common.truth.DoubleSubject.TolerantDoubleComparison.hashCode() Object.hashCode()
is not supported on TolerantDoubleComparisoncom.google.common.truth.extensions.proto.IterableOfProtosFluentAssertion.equals(Object) Do not callequals()
on aIterableOfProtosFluentAssertion
.com.google.common.truth.extensions.proto.IterableOfProtosFluentAssertion.hashCode() IterableOfProtosFluentAssertion
does not supporthashCode()
.com.google.common.truth.extensions.proto.IterableOfProtosSubject.isInOrder() Protos do not implementComparable
, so you must supply a comparator.com.google.common.truth.extensions.proto.IterableOfProtosSubject.isInStrictOrder() Protos do not implementComparable
, so you must supply a comparator.com.google.common.truth.extensions.proto.LiteProtoSubject.isEqualTo(MessageLite.Builder) A Builder can never compare equal to a MessageLite instance. Usebuild()
, orbuildPartial()
on the argument to get a MessageLite for comparison instead. Or, if you are passingnull
, useSubject.isNull()
.com.google.common.truth.extensions.proto.LiteProtoSubject.isNotEqualTo(MessageLite.Builder) A Builder will never compare equal to a MessageLite instance. Usebuild()
, orbuildPartial()
on the argument to get a MessageLite for comparison instead. Or, if you are passingnull
, useSubject.isNotNull()
.com.google.common.truth.extensions.proto.MapWithProtoValuesFluentAssertion.equals(Object) Do not callequals()
on aMapWithProtoValuesFluentAssertion
.com.google.common.truth.extensions.proto.MapWithProtoValuesFluentAssertion.hashCode() MapWithProtoValuesFluentAssertion
does not supporthashCode()
.com.google.common.truth.extensions.proto.MultimapWithProtoValuesFluentAssertion.equals(Object) Do not callequals()
on aMultimapWithProtoValuesFluentAssertion
.com.google.common.truth.extensions.proto.MultimapWithProtoValuesFluentAssertion.hashCode() MultimapWithProtoValuesFluentAssertion
does not supporthashCode()
.com.google.common.truth.extensions.proto.ProtoFluentAssertion.equals(Object) Do not callequals()
on aProtoFluentAssertion
. UseProtoFluentAssertion.isEqualTo(Message)
instead.com.google.common.truth.extensions.proto.ProtoFluentAssertion.hashCode() ProtoFluentAssertion
does not supporthashCode()
. UseProtoFluentAssertion.isEqualTo(Message)
for testing.com.google.common.truth.FloatSubject.isEquivalentAccordingToCompareTo(Float) UseFloatSubject.isWithin(float)
orFloatSubject.isEqualTo(java.lang.Object)
instead (see documentation for advice).com.google.common.truth.FloatSubject.TolerantFloatComparison.equals(Object) Object.equals(Object)
is not supported on TolerantFloatComparison. If you meant to compare floats, useFloatSubject.TolerantFloatComparison.of(float)
instead.com.google.common.truth.FloatSubject.TolerantFloatComparison.hashCode() Object.hashCode()
is not supported on TolerantFloatComparisoncom.google.common.truth.IntegerSubject.isEquivalentAccordingToCompareTo(Integer) UseSubject.isEqualTo(java.lang.Object)
instead. Integer comparison is consistent with equality.com.google.common.truth.IntegerSubject.TolerantIntegerComparison.equals(Object) Object.equals(Object)
is not supported on TolerantIntegerComparison. If you meant to compare ints, useIntegerSubject.TolerantIntegerComparison.of(int)
instead.com.google.common.truth.IntegerSubject.TolerantIntegerComparison.hashCode() Object.hashCode()
is not supported on TolerantIntegerComparisoncom.google.common.truth.IntStreamSubject.intStreams() Instead ofabout(intStreams()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(intStreams()).that(...)
, use justassertThat(...)
.com.google.common.truth.IterableSubject.isNoneOf(Object, Object, Object...) You probably meant to callIterableSubject.containsNoneOf(java.lang.Object, java.lang.Object, java.lang.Object...)
instead.com.google.common.truth.IterableSubject.isNotIn(Iterable<?>) You probably meant to callIterableSubject.containsNoneIn(java.lang.Iterable<?>)
instead.com.google.common.truth.IterableSubject.UsingCorrespondence.equals(Object) Object.equals(Object)
is not supported on Truth subjects or intermediate classes. If you are writing a test assertion (actual vs. expected), use methods liksIterableSubject.UsingCorrespondence.containsExactlyElementsIn(Iterable)
instead.com.google.common.truth.IterableSubject.UsingCorrespondence.hashCode() Object.hashCode()
is not supported on Truth types.com.google.common.truth.IterableSubject.UsingCorrespondence.toString() Object.toString()
is not supported on Truth subjects.com.google.common.truth.LongStreamSubject.longStreams() Instead ofabout(longStreams()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(longStreams()).that(...)
, use justassertThat(...)
.com.google.common.truth.LongSubject.isEquivalentAccordingToCompareTo(Long) UseSubject.isEqualTo(java.lang.Object)
instead. Long comparison is consistent with equality.com.google.common.truth.LongSubject.TolerantLongComparison.equals(Object) Object.equals(Object)
is not supported on TolerantLongComparison. If you meant to compare longs, useLongSubject.TolerantLongComparison.of(long)
instead.com.google.common.truth.LongSubject.TolerantLongComparison.hashCode() Object.hashCode()
is not supported on TolerantLongComparisoncom.google.common.truth.OptionalDoubleSubject.optionalDoubles() Instead ofabout(optionalDoubles()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(optionalDoubles()).that(...)
, use justassertThat(...)
.com.google.common.truth.OptionalIntSubject.optionalInts() Instead ofabout(optionalInts()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(optionalInts()).that(...)
, use justassertThat(...)
.com.google.common.truth.OptionalLongSubject.optionalLongs() Instead ofabout(optionalLongs()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(optionalLongs()).that(...)
, use justassertThat(...)
.com.google.common.truth.OptionalSubject.optionals() Instead ofabout(optionals()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(optionals()).that(...)
, use justassertThat(...)
.com.google.common.truth.PathSubject.paths() Instead ofabout(paths()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(paths()).that(...)
, use justassertThat(...)
.com.google.common.truth.StreamSubject.isEqualTo(Object) streamA.isEqualTo(streamB)
always fails, except when passed the exact same stream reference. If you really want to test object identity, you can eliminate this deprecation warning by usingSubject.isSameInstanceAs(java.lang.Object)
. If you instead want to test the contents of the stream, useStreamSubject.containsExactly(java.lang.Object...)
or similar methods.com.google.common.truth.StreamSubject.isNotEqualTo(Object) streamA.isNotEqualTo(streamB)
always passes, except when passed the exact same stream reference. If you really want to test object identity, you can eliminate this deprecation warning by usingSubject.isNotSameInstanceAs(java.lang.Object)
. If you instead want to test the contents of the stream, collect both streams to lists and perform assertions likeSubject.isNotEqualTo(java.lang.Object)
on them. In some cases, you may be able to useStreamSubject
assertions likeStreamSubject.doesNotContain(java.lang.Object)
.com.google.common.truth.StreamSubject.streams() Instead ofabout(streams()).that(...)
, use justthat(...)
. Similarly, instead ofassertAbout(streams()).that(...)
, use justassertThat(...)
.com.google.common.truth.StringSubject.isEquivalentAccordingToCompareTo(String) UseSubject.isEqualTo(java.lang.Object)
instead. String comparison is consistent with equality.com.google.common.truth.Subject.equals(Object) Object.equals(Object)
is not supported on Truth subjects. If you are writing a test assertion (actual vs. expected), useSubject.isEqualTo(Object)
instead.com.google.common.truth.Subject.hashCode() Object.hashCode()
is not supported on Truth subjects.com.google.common.truth.Subject.toString() Object.toString()
is not supported on Truth subjects.