<div dir="ltr">There&#39;s maybe a need for both synchronous and asynchronous testing, no? It&#39;s true that I wasn&#39;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?<div><br></div><div>If I take the example of our collectors such as the &quot;NumericDataPointCollector&quot; : it&#39;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.<div><div><br></div><div>About TestSubscriber, I didn&#39;t know it, so thanks for sharing this! I&#39;ll try to use it instead of the &quot;toBlocking&quot; workaround in my last PR.</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 6, 2016 at 5:19 PM, Michael Burman <span dir="ltr">&lt;<a href="mailto:miburman@redhat.com" target="_blank">miburman@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
While it&#39;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.<br>
<br>
We don&#39;t currently write our tests well, that&#39;s true. We should be using TestSubscriber in multiple place instead of our current .toBlocking().lastOrDefault(<wbr>null) (workaround). I really don&#39;t want the latter to be used more, since it&#39;s used in situations where it shouldn&#39;t be. Tests should be reactive just like our other code, and AssertJ can&#39;t provide that.<br>
<br>
  -  Micke<br>
<div><div class="h5"><br>
----- Original Message -----<br>
From: &quot;Joel Takvorian&quot; &lt;<a href="mailto:jtakvori@redhat.com">jtakvori@redhat.com</a>&gt;<br>
To: &quot;Discussions around Hawkular development&quot; &lt;<a href="mailto:hawkular-dev@lists.jboss.org">hawkular-dev@lists.jboss.org</a>&gt;<br>
Sent: Tuesday, September 6, 2016 5:24:16 PM<br>
Subject: [Hawkular-dev]  Assertj framework<br>
<br>
Hello,<br>
<br>
I&#39;d like to propose the addition of the &quot;assertj&quot; lib in test scope for hawkular-metrics (and/or other modules).<br>
<br>
If you don&#39;t know it, assertj is basically a &quot;fluent assertion framework&quot;. You write assertions like :<br>
<br>
assertThat(result) . extracting( DataPoint :: getTimestamp) . containsExactly( 0L , 1L , 5L , 7L , 10L );<br>
<br>
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.<br>
<br>
Also, the fact that it&#39;s &quot;fluent&quot; helps a lot when you write a test, because your IDE auto-completion will help you a lot to find what&#39;s the assertion you&#39;re looking for - something that is not so easy with hamcrest.<br>
<br>
I see it as a kind of virtuous cycle: tests are easier to write, easier to read, so you write more tests / better tests.<br>
<br>
Would you be ok to give it a try?<br>
<br>
If you want to read about it: official site is there <a href="http://joel-costigliola.github.io/assertj/" rel="noreferrer" target="_blank">http://joel-costigliola.<wbr>github.io/assertj/</a><br>
or an article that promotes it nicely : <a href="https://www.infoq.com/articles/custom-assertions" rel="noreferrer" target="_blank">https://www.infoq.com/<wbr>articles/custom-assertions</a><br>
or an example of file I&#39;d like to push, if you&#39;re ok with assertj :) : <a href="https://github.com/jotak/hawkular-metrics/blob/72e2f95f7e19c9433ce44ee83d15a9978503d9f5/core/metrics-core-service/src/test/java/org/hawkular/metrics/core/service/MetricsServiceImplTest.java" rel="noreferrer" target="_blank">https://github.com/jotak/<wbr>hawkular-metrics/blob/<wbr>72e2f95f7e19c9433ce44ee83d15a9<wbr>978503d9f5/core/metrics-core-<wbr>service/src/test/java/org/<wbr>hawkular/metrics/core/service/<wbr>MetricsServiceImplTest.java</a><br>
<br>
Joel<br>
<br>
</div></div>______________________________<wbr>_________________<br>
hawkular-dev mailing list<br>
<a href="mailto:hawkular-dev@lists.jboss.org">hawkular-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/hawkular-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/hawkular-dev</a><br>
______________________________<wbr>_________________<br>
hawkular-dev mailing list<br>
<a href="mailto:hawkular-dev@lists.jboss.org">hawkular-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/hawkular-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/hawkular-dev</a><br>
</blockquote></div><br></div>