1.3.0
In this release, our assertions on Java 8 types begin to move from the truth-java8-extensions
artifact and the Truth8
class to the main truth
artifact and the Truth
class. This change should not break compatibility for any supported JDK or Android version, even users who test under old versions of Android without API desugaring. Additionally, we will never break binary compatibility, though some users will have to make changes to their source code in order for it to compile against newer versions.
This change will be routine for most users, but we're providing as much information as we can for any users who do encounter problems.
We will post fuller instructions for migration later on, once we've learned more from our internal migration efforts. For now, you may find that you need to make one kind of change, and you may elect to make others. (If we missed anything, please open an issue to report problems or request help.)
The change you might need to make:
- By adding new overloads of
Truth.assertThat
, we cause some code to fail to compile because of an overload ambiguity. This is rare, but it can happen if you static import bothTruth.assertThat
and some otherassertThat
method that includes overloads forOptional
orStream
. (It does not happen forTruth8.assertThat
, though, except with the Eclipse compiler. Nor it does necessarily happen for otherassertThat(Stream)
andassertThat(Optional)
methods.) If this happens to you, you'll need to remove one of the static imports, changing the corresponding call sites from "assertThat
" to "FooSubject.assertThat
."- Alternatively, you may choose to wait until we make further changes to the new
Truth.assertThat
overloads. Once we make those further changes, you may be able to simultaneously replace all your imports ofTruth8.assertThat
with imports ofTruth.assertThat
as you upgrade to the new version, likely without introducing overload ambiguities.
- Alternatively, you may choose to wait until we make further changes to the new
The changes you might elect to make:
-
If you use
Truth8.assertThat(Stream)
orTruth8.assertThat(Optional)
, you can migrate to the new overloads inTruth
. If you static importTruth8.assertThat
, you can usually make this change simply by replacing that static import with a static import ofTruth.assertThat
—or, if you already have an import ofTruth.assertThat
, by just removing the import ofTruth8.assertThat
. (If you additionally use less common assertion methods, likeassertThat(OptionalInt)
, you'll want to use both imports for now. Later, we'll moveassertThat(OptionalInt)
and friends, too.) We recommend making this change now, since your calls toTruth8.assertThat
will fail to compile against some future version of Truth, unless you plan to wait to update your Truth dependency until we've made all our changes for Java 8 types. -
If you use
assertWithMessage(...).about(streams()).that(...)
,expect.about(optionals()).that(...)
, or similar, you can remove your call toabout
. This change will never be necessary; it is just a simplification. -
If you depend on
truth-java8-extension
, you may remove it. All its classes are now part of the maintruth
artifact. This change, too, is not necessary; it is just a simplification. (OK, if your build system has a concept of strict deps, there is a chance that you'll need to add deps ontruth
to replace your deps ontruth-java8-extension
.)
Finally, the changelog for this release:
- Made
StreamSubject
avoid collecting theStream
until necessary, and made itsisEqualTo
andisNotEqualTo
methods no longer always throw. (f8ecaec) - Added
assertThat
overloads forOptional
andStream
to the mainTruth
class. (37fd8be) - Added
that
overloads to make it possible to write type-specific assertions when usingexpect.that(optional)
andexpect.that(stream)
. (ca7e8f4) - Moved the
truth-java8-extension
classes into the maintruth
artifact. There is no longer any need to depend ontruth-java8-extension
, which is now empty. (We've also removed theTruth8
GWT module.) (eb0426e)
Again, if you have any problems, please let us know.