Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do a comparison chart of Truth, Fest, JUnit Asserts, Hamcrest, etc. #43

Closed
cgruber opened this issue Sep 7, 2012 · 14 comments
Closed
Assignees
Labels
type=documentation Documentation that is other than for an API
Milestone

Comments

@cgruber
Copy link
Contributor

cgruber commented Sep 7, 2012

No description provided.

@ghost ghost assigned cgruber Sep 7, 2012
@mwanji
Copy link

mwanji commented Jan 11, 2013

I'd be interested in the comparison with FEST, as Truth seems very similar.

@JanecekPetr
Copy link

Also, AssertJ. http://joel-costigliola.github.io/assertj/

@cgruber cgruber removed their assignment Jun 20, 2014
@wernight
Copy link

AssertJ seems to be the most complete of the lot. I wonder if Truth has some advantages over it at the moment.

@velo
Copy link

velo commented Dec 18, 2014

Me either

@cgruber
Copy link
Contributor Author

cgruber commented Jan 23, 2015

I wrote a G+ comment about FEST/AssertJ that I should turn into a FAQ answer, but have to dig it out.

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.

Leaving this here for reference until I update the docs.

@kevinb9n
Copy link
Contributor

I think the most important ones to compare against are assertj (because it's the strongest) and hamcrest (due to its legacy popularity).

@kluever kluever self-assigned this Jun 10, 2015
@jaredsburrows
Copy link

I currently use Hamcrest. I am thinking of switching to AssertJ. Why would I use Truth over AssertJ?

@qinfchen
Copy link

@jaredsburrows what library did you end up using?

@jaredsburrows
Copy link

@qinfchen I use AssertJ.

For Java 7 builds(mainly for Android) - I use Squares AssertJ: com.squareup.assertj:assertj-android:1.1.1

For Java 8+ builds or Android +Retrolambda - I use AssertJ 3+: org.assertj:assertj-core:3.4.1

@qinfchen
Copy link

thanks! @jaredsburrows Any particular reasons? I am leaning toward using AssertJ as well. Truth is a great assertion library and it woks well in conjunction with other assertion libraries. Hamcrest is more composble and more powerful. Assertj seems to do everything that hamcrest does, but better IMO.

@jaredsburrows
Copy link

@qinfchen
Google Truth and AssertJ both are very similar. I first saw Square's AssertJ library with Android matchers. I got hooked and started using it everywhere.

Hamcrest is more composble and more powerful.

I find this hard to use as it is not "fluent" like AssertJ is.

@IgorGanapolsky
Copy link

It's funny that Google themselves are advocating Hamcrest, and Hamcrest only (nothing else) here: https://developer.android.com/studio/test/index.html. Don't they think developers should know about other options?

@jaredsburrows
Copy link

Google uses hamcrest in Espresso. But yes, there are other options.
On Jun 14, 2016 6:18 AM, "Igor Ganapolsky" [email protected] wrote:

It's funny that Google themselves are advocating Hamcrest, and
Hamcrest only (nothing else) here:
https://developer.android.com/studio/test/index.html. Don't they think
developers should know about other options?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#43 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABqMSMLmJLAWXp3XY9T_7suKubYOvOD0ks5qLqo7gaJpZM4AJFIP
.

@cgruber
Copy link
Contributor Author

cgruber commented Aug 10, 2016

I'm closing this, as we have a preliminary comparison page here: http://google.github.io/truth/comparison

Any inaccuracies or improvements are welcome, but should be new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=documentation Documentation that is other than for an API
Projects
None yet
Development

No branches or pull requests

10 participants