Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Instant Mockito – a Review

DZone's Guide to

Instant Mockito – a Review

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

Instant Mockito is just a little book covering https://code.google.com/p/mockito/, but that’s not a bad objective in itself. Mockito, after all, is one of the most commonly used Java mocking libraries. (I happen to prefer other mocking libraries better, but that’s another story).

The book organized around a single coherent example which – if contrived – is easy enough to grok and helps unify the content. Through that example this book does a pretty reasonable job of explaining how to use Mockito’s capabilities.

As with many technical books, the layout/indentation of the code examples left something to be desired; I don’t think the author was done any favours by his editor. And I did struggle a bit with little with the omission of import statements in the examples; it wasn’t clear which class the static mock() method had been imported from, for example. The first mention of Matchers was also confusing; both Mockito and the widely used Hamcrest library define a class of this name.

I did also find myself wondering why Mockito’s @Mock annotation hadn’t been used; only later was that explained. I would rather the author had shown the use of @Mock first, and then only later (as a mechanism that involves much more boilerplate), covered the use of mock().

Overall, this book doesn’t cover very much more than what’s covered in Mockito’s own Javadoc API. So is it worth buying? Well, yes, probably… the content is solid enough, you’ll read it quickly, and will end up with a pretty understanding of what Mockito is and how to use it. Which I am sure is what the author set out to do.

Disclaimer: I was asked to review this book – and provided a free eBook for my trouble – by Packt Publishing.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Published at DZone with permission of Dan Haywood, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}