Truth 0.33
Changes to existing Subjects and Core classes
- [API] Introduce
ExpectFailure
, a common mechanism for capturing failures in Truth, allowing tests to verify Truth failures without catchingAssertionError
. Intended primarily for testingSubject
implementations. - [API] Deprecate
PrimitiveDoublesArraySubject.hasvaluesWithin()
and
PrimitiveFloatArraySubject.hasvaluesWithin()
. - [SPI] Introduce
AbstractFailureStrategy
; users creating their own customFailureStrategy
implementations are encouraged to migrate to this class if possible. - [SPI] Add
Subject.ignoreCheck()
which is similar toSubject.check()
but passes a no-op failure strategy, to
allow chaining to continue when non-short-circuiting failure strategies are used (such asExpect
). - Restrict visibility of the
Platform
class, which was never intended to be part of the public API. Most usages can simply be removed / inlined, usages that require GWT compatibility should open feature requests.
Extensions
-
Protocol Buffers
- Permit Iterables for field numbers, descriptors, and handles with the protocol buffers FieldScope APIs
- Fix comparison rules for map fields.
Fixes
- Typo in
LiteProtoTruth
docs assertThat(Double.NaN).isNaN()
in gwt/j2cl now working properly.- Variety of improvements to error messages in MultimapSubject and MapSubject
ThrowableSubject
and Java8Optional*Subject
tests now useExpectFailure
which exposed some bad behavior, now fixed.IterableSubject
adds type information to errors when string representations are the same, to clarify some
ambiguous cases
Misc
- Internal clean-up of
FailureStrategy
usage to prepare forFailureStrategy
becoming fully abstract - Source now formatted via google-java-format
- For users of ErrorProne, add
@SuppressWarnings("TruthSelfEquals")
since Truth tests sometimes need to
test equality against the same reference to prove behavior. Generally ErrorProne will flag that as an error,
since it can never fail (and is therefore usually a badly written test) - Some docs on
OptionalSubject
updated relating to complex assertions. - Fix some sample code containing a bug.
For details, see the complete list of included commits.