Truth assertions library comparing to AssertJ
Asked Answered
R

1

11

I used FEST-Assert and moved to AssertJ after it stopped development.

Recently I was pointed to Google repository with another assertions library Truth (http://google.github.io/truth/).

Reading the examples I can not find any advantage of start using it over AssertJ. So it is just matter of taste what to use. But maybe I missed the point, did I?

Restful answered 24/9, 2015 at 6:43 Comment(1)
truth.dev/comparison.htmlBrushwood
S
12

From one of their comments at GitHub:

The core difference is that the design of Truth includes two specific areas of extensibility - that of a strategy for proposition failure - such that a "subject" for Integers, or a subject for Strings can be re-used in the context of completely different results for failure. A notable example is the distinction between JUnit's use of AssertionError and it's AssumptionViolationException. Truth lets you use the same proposition classes for both.

The other area of flexibility is the ability to create new assertion/proposition types and hook them in without declaring possibly conflicting static methods to import. This can be for new types (say, adding protobufs) or for new uses of existing types (say, Strings that are treated as Uris). This is the assertAbout() feature.

Other than that, Truth is very similar to AssertJ, since it was inspired by FEST, of which AssertJ is a fork of the 2.0 development line.

To sum up, Truth is designed to be a bit more extensible and flexible, but AssertJ will be great (possibly the greatest) for assertions on standard types.

Struggle answered 26/9, 2015 at 21:56 Comment(1)
Thanks, Michal, I think it is matter to try and find outRestful

© 2022 - 2024 — McMap. All rights reserved.