Wednesday, April 3, 2013
jUnit Testing With Mockito
Mockito is a simple mocking framework. Basically you can test pieces of code that have other class objects and pretend to test those other clas objects. This allows you to test the class you want to test without worrying about how other classes and methods from those classes might impact your testing. I first head about class mocking via EasyMock. EasyMock was kind of easy but it did have some quirks to it. Mockito is a bit more intuitive. That said, I couldn't find a decent guide on how to use the various capabilities of Mockito in jUnit testing. In some cases, I saw people mistakenly using Mockito to test the mocked class. Other times, I found imcomplete and vague pieces of code with little to no explaination. So, I decided to write a short eBook on how to do jUnit testing with Mockito. Now, it doesn't cover everything. However, it is a good jumping point to get a feel on how to use Mockito to test your code. The examples are very simple. The test code is a bit light hearted and, dare I say, fun to play with? I'd like to think it is very straight forward and easy to understand. Feedback is welcome. http://www.kengpl.com/ebooks/
Subscribe to:
Posts (Atom)