<div dir="ltr"><div><div>Hi guys,<br>I just wanted to share some the experience of the last few weeks (and also to have a record for myself):<br></div><div><br>- to have your code testable, it is a good idea to use dependency injection (e.g., all the critical references are passed in the constructor) - this is what we already do<br>


<br></div>- to test such a highly decomposed code (in jDEECo, you put an instance of KRepository into an instance of KManager which you put into Runtime, etc. - you get the picture), it is very convenient to use some mock-up library. And this is exactly what I wanted to share: I have been really pleasantly surprised by <b>mockito</b>. It is really easy to write the mocks and the unit tests are then so much easier to write (and can be so much more fine-grained) - I definitely recommend to check it out.<br>


<br></div><div>Web:<br>        <a href="https://code.google.com/p/mockito/">https://code.google.com/p/mockito/</a><br></div>Maven:<br><div>        <span style="font-family:courier new,monospace"><dependency><br> </span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    </span>   <groupId>org.mockito</groupId><br>

        <artifactId>mockito-all</</span><span style="font-family:courier new,monospace">artifactId><br>        <version>1.9.5</version><br>    </dependency><br><br></span></div><div>Here are some other unit-testing tools that helped me:<span style="font-family:courier new,monospace">  </span><br>

</div><div>- <a href="http://www.stefan-birkner.de/system-rules/">http://www.stefan-birkner.de/system-rules/</a> for testing System calls<br><span style="font-family:courier new,monospace">     <dependency><br>         <groupId>com.github.stefanbirkner</groupId><br>

         <artifactId>system-rules</artifactId><br>         <version>1.3.1</version><br>     </dependency></span><br><br></div><div>- <a href="http://junit-addons.sourceforge.net/">http://junit-addons.sourceforge.net/</a> for things like FileAssert (comparing text/binary files with nice reports), ListAssert (the same for lists).<br>

<span style="font-family:courier new,monospace">     <dependency><br>         <groupId>junit-addons</groupId><br>         <artifactId>junit-addons</artifactId><br>         <version>1.4</version><br>

     </dependency></span><br><br>- I also use a modification of the DynamicSuite class to invoke all the tests in a package (and subpackages) - <a href="http://www.anzaan.com/2012/01/automatic-unit-testing-test-packages-recursively-in-junit/">http://www.anzaan.com/2012/01/automatic-unit-testing-test-packages-recursively-in-junit/</a>. Note that I had to fix small bugs in the code before actually using it.<br>

</div><div></div><div><br></div><div>Have fun<br></div><div>Jarda<br></div></div>