-
Notifications
You must be signed in to change notification settings - Fork 261
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
Comments
I'd be interested in the comparison with FEST, as Truth seems very similar. |
Also, AssertJ. http://joel-costigliola.github.io/assertj/ |
AssertJ seems to be the most complete of the lot. I wonder if Truth has some advantages over it at the moment. |
Me either |
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. |
I think the most important ones to compare against are assertj (because it's the strongest) and hamcrest (due to its legacy popularity). |
I currently use Hamcrest. I am thinking of switching to AssertJ. Why would I use Truth over AssertJ? |
@jaredsburrows what library did you end up using? |
@qinfchen I use AssertJ. For Java 7 builds(mainly for Android) - I use Squares AssertJ: For Java 8+ builds or Android +Retrolambda - I use AssertJ 3+: |
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. |
@qinfchen
I find this hard to use as it is not "fluent" like AssertJ is. |
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? |
Google uses hamcrest in Espresso. But yes, there are other options.
|
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. |
No description provided.
The text was updated successfully, but these errors were encountered: