[Hawkular-dev] Assertj framework

Joel Takvorian jtakvori at redhat.com
Tue Sep 6 12:05:07 EDT 2016


There's maybe a need for both synchronous and asynchronous testing, no?
It's true that I wasn't considering assertj under the angle of Observables,
but does it really mean that we should eliminate the benefits of using a
good library for all synchronous pieces of code?

If I take the example of our collectors such as the
"NumericDataPointCollector" : it's used in a RX transformation flow, but
the class itself has nothing asynchronous, it has some methods that I think
are complex enough to be put under synchronous unit tests.

About TestSubscriber, I didn't know it, so thanks for sharing this! I'll
try to use it instead of the "toBlocking" workaround in my last PR.

On Tue, Sep 6, 2016 at 5:19 PM, Michael Burman <miburman at redhat.com> wrote:

> Hi,
>
> While it's nice to have easier tests, this does not really work for
> metrics as we use RxJava and AssertJ has no support for any reactive
> frameworks. The assertJ provides next to nothing in that context, as most
> of our implementation is reactive in behavior. There are two projects that
> have tried to improve situation with RxJava, one abandoned because the
> author thinks TestSubscriber is better and second one is quite incomplete.
>
> We don't currently write our tests well, that's true. We should be using
> TestSubscriber in multiple place instead of our current
> .toBlocking().lastOrDefault(null) (workaround). I really don't want the
> latter to be used more, since it's used in situations where it shouldn't
> be. Tests should be reactive just like our other code, and AssertJ can't
> provide that.
>
>   -  Micke
>
> ----- Original Message -----
> From: "Joel Takvorian" <jtakvori at redhat.com>
> To: "Discussions around Hawkular development" <
> hawkular-dev at lists.jboss.org>
> Sent: Tuesday, September 6, 2016 5:24:16 PM
> Subject: [Hawkular-dev]  Assertj framework
>
> 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
>
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
> _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hawkular-dev/attachments/20160906/9d15155b/attachment-0001.html 


More information about the hawkular-dev mailing list