[Hawkular-dev] Assertj framework

Joel Takvorian jtakvori at redhat.com
Tue Sep 6 10:24:16 EDT 2016


Hello,

I'd like to propose the addition of the "assertj" lib in test scope for
hawkular-metrics (and/or other modules).

If you don't know it, assertj is basically a "fluent assertion framework".
You write assertions like :

*assertThat(result).extracting(DataPoint::getTimestamp).containsExactly(0L,
1L, 5L, 7L, 10L);*

It has a very rich collection of assertions, I find it particularly
powerful when working on collections, whether they are sorted or not,
whether they have nested objects or not.

Also, the fact that it's "fluent" helps a lot when you write a test,
because your IDE auto-completion will help you a lot to find what's the
assertion you're looking for - something that is not so easy with hamcrest.

I see it as a kind of virtuous cycle: tests are easier to write, easier to
read, so you write more tests / better tests.

Would you be ok to give it a try?

If you want to read about it: official site is there
http://joel-costigliola.github.io/assertj/
or an article that promotes it nicely :
https://www.infoq.com/articles/custom-assertions
or an example of file I'd like to push, if you're ok with assertj :) :
https://github.com/jotak/hawkular-metrics/blob/72e2f95f7e19c9433ce44ee83d15a9978503d9f5/core/metrics-core-service/src/test/java/org/hawkular/metrics/core/service/MetricsServiceImplTest.java

Joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hawkular-dev/attachments/20160906/a9fea2f8/attachment.html 


More information about the hawkular-dev mailing list