Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Truth assertions library comparing to AssertJ

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?

like image 798
Eugen Martynov Avatar asked Sep 24 '15 06:09

Eugen Martynov


1 Answers

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.

like image 181
Michal Kordas Avatar answered Oct 13 '22 14:10

Michal Kordas