Nowadays developers are expected to write unit tests. While simple in theory, in practice writing high-quality unit tests can turn out to be a real challenge. This book will help.
This book explains in detail how to implement unit tests using very popular open source Java technologies: JUnit, TestNG, Mockito and AssertJ.
It presents a range of techniques necessary to write high quality unit tests – e.g. mocks, parametrized tests and matchers. It also discusses trade-offs related to the choices we have to make when dealing with some real-life code issues.
The book stresses the importance of writing readable and maintainable unit tests, and puts a lot of stress on code quality. It shows how to achieve testable code and to eliminate common mistakes by following the Test Driven Development (TDD) approach. Every topic discussed in the book is illustrated with code examples, and each chapter is accompanied by some exercises.
By reading this book you will:
If you buy the printed version of any "Practical Unit Testing" book, you can buy ePub + mobi + PDF for 10$! Just send me a picture of the book on your desk.
Already have one of "Practical Unit Testing" e-books and now you want to buy the other one? It will cost you $5 only. Contact me, please.
If you want to buy electronic or paper versions of the Practical Unit Testing book for your team or company, then contact me regarding the final price, please.
[...] for those less familiar with testing and using TestNG and Mockito [...] this book is a totally must read as it gently introduces reader to world of proper unit testing using best tools available in Java world.
This book gives a lot of good, general advice on unit testing in general (and not relevant only to Java), but it also brings one very quickly in working order with its two proponent tools. In two hours of reading, I knew more of the usage of TestNG and Mockito than after several days of Web crawling. And I have learned how to do TDD (test driven development) correctly.
Tomek does also a good job of not just pushing his own preferences in Java unit testing, but presenting the available choices either for test strategies or for unit testing tools.
I would recommend this book to every developer concerned by code quality, especially if you are working in a Java context.
[...]World would be better if every programmer read this book. The book focuses not only on the toolset which perhaps will be outdated very quickly but also/mainly on the OO design and testing principles.
I liked the approach of the author to have an open view on unit testing and presenting all the available choices for testing strategies or tools selection instead of just pushing his own opinion.
[...]the book contains a high percentage of general unit testing knowledge that can be applied (mostly) independently of the language and tools that you are using.
This book is highly recommendable to all software developers interested in unit testing, particularly if you are working in a Java context.
Reviews are cool, but why not decide on your own? Here you will find one of the last chapters from the "Practical Unit Testing with TestNG and Mockito" book. The chapter explains how to make unit tests manageable, so they do not become a burden as the project develops and changes are introduced. To a large extent this chapter is independent from the underlying testing framework (JUnit or TestNG), so its content in the "Practical Unit Testing with JUnit and Mockito" book is very similar.
P.S. Hint: use "fullscreen" option. :)
My name is Tomek Kaczanowski, and I’m happy to present to you the results of my hard work. This book have been written on the basis of my experience as a senior Java developer, trainer, mentor, technical team leader and merciless code reviewer. :)
The book have been proofread by several TDD & Java experts, and corrected by a native speaker, so I feel pretty confident about recommending it. Okay then, let’s forget about modesty: I reckon these really are the best books dealing with unit tests on the market! I hope you’ll share my opinion - when you’ve read them! :)
Personally, I would have been really happy to have had the chance to read book like this some time ago: it would have spared me several grey hairs, for sure! :) I would also be happy if my colleagues were to read them and follow the advice they would find there... :)Twitter Medium LinkedIn e-mail