Showing posts with label JUnit. Show all posts
Showing posts with label JUnit. Show all posts

Wednesday, April 2, 2014

Difference between Stub and Mock object in Java Unit testing - JUnit

JUnit is the most popular framework for unit testing Java code. Unit testing is used to test a single programming unit e.g. a class or a method, in-fact many Java developer write unit test on per method basis. Stub and Mock objects are two concepts which helps during unit testing, they are not real object, but act like real object for unit testing purpose. By the way, If you are absolutely beginner in Java Unit testing then you can see this post to learn how to create JUnit test in Eclipse. Coming back to Stubs and Mocks, One reason of using Stub and Mock object is dependency of one unit into another. Since in real world, most unit doesn't work in isolation, they use dependent class and object to complete there task. One of the common testing approach to test a unit, which depends on other unit is by using Stubs and Mock objects. They help to reduce complexity, which may be require to create actual dependent object. In this tutorial, we will learn few basic difference between Stub and Mock object in Java Unit testing. This post is rather small to tackle this whole topic, at best it just provide an introduction. I would suggest to follow on some good books on Java Unit testing e.g. Pragmatic Unit Testing in Java. This is one of the must read book in Java Unit testing, and my personal favourite as well. Apart from teaching basics of Unit testing it also gives a nice overview of Mock objects and mock framework. Actually, from there, I came to know about EasyMock and jMock frameworks and how useful they can be. Even if you have been using JUnit and unit testing, you can learn a lot form this book. It's like learning from basics to best practices of Unit testing. Mockito is another useful library enables mocks creation, verification and stubbing.
Read more �

Sunday, October 14, 2012

Liens pratiques de la semaine

Vous trouverez dans ce billet une s�lection de liens pratiques autour des technologies Java qui m'ont particuli�rement int�ress�es ces derni�res semaines.

Eclipse 
  • Eclipse RAP 1.5.1 est disponible (voir les bugs r�solus).
  • Un article qui montre comment r�aliser un build du SDK d'Eclipse.
  • Un billet qui fait un point sur Eclipse 4 et pourquoi nous devrions y aller.
  • Une s�rie de billets sur les bonnes pratiques pour faire de l'Eclipse RCP. Actuellement seuls 3 billets sont disponibles (billet 1, billet 2 et billet 3).
  • Fuzz Box un petit plugin qui permet de g�n�rer des diagrammes UML � partir de classe Java.
Java
  • GWT 2.5 RC2 est disponible (page des nouveaut�s).
  • Un article sur Hibernate OGM qui montre comment d�buter.
  • La JSR 353 pr�sent�e � JavaOne 2012 proposera une API pour le support JSON, enfin !! (source Developpez.com).
  • Un article qui pr�sente la fonctionnalit� Rules au niveau de JUnit. Pour faire simple, cela permet de r�aliser des op�rations avant et apr�s un test.
Divers
  • Adobe publie une police de caract�res d�di�e aux d�veloppeurs.
  • Quelques conseils pour les d�butants Java qui souhaitent r�ussir son entretien.
  • Reveal.js, Impress.js, Html5slides, Csss sont des frameworks HTML5 pour faire des pr�sentations (source Korben).
  • Un site qui permet de retrouver de vieilles versions de logiciel (pratique pour retrouver un vieux Firefox).
  • Deux id�es de sources de donn�es pour r�aliser une application � base de NoSQL (ClickStream et TimeSeries) (source CastCodeurs).
  • Une d�mo HTML5 avec WebGL qui permet de modifier en temps r�el l'image issu d'une WebCam.