See my books:

The kanban book
is in polish.

Source code
About the Author

Questions regarding my books?
E-mail me at
This book explains in detail how to implement unit tests using very popular open source Java technologies. 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 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:
  • Grasp the role and purpose of unit tests
  • Write high-quality, readable and maintainable unit tests
  • Learn how to use TestNG and Mockito (but also other useful tools)
  • Avoid common pitfalls when writing unit tests
  • Recognize bad unit tests, and fix them in no time
  • Develop code following the Test Driven Development (TDD) approach
  • Use mocks, stubs and test-spies intelligently
  • Measure the quality of your tests using code coverage and mutation testing
  • Learn how to improve your tests’ code so it is an asset and not a burden
  • Test collections, expected exceptions, time-dependent methods and much more
  • Customize test reports so that they show you what you really need to know
  • Master tools and techniques your team members have never even heard of (priceless!) :)
Nowadays every developer is 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.
Practical Unit Testing with TestNG and Mockito
PDF A4 + ePub + Kindle Buy PDF A4 + ePub + Kindle $25
PDF USLetter + ePub + Kindle Buy PDF USLetter + ePub + Kindle $25
Printed US   UK   DE
ES   IT   FR  
Practical Unit Testing with JUnit and Mockito
PDF A4 + ePub + Kindle Buy PDF A4 + ePub + Kindle $25
PDF USLetter + ePub + Kindle Buy PDF USLetter + ePub + Kindle $25
Printed US   UK   DE
ES   IT   FR  

Personal Discounts

  • 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. Please contact me.

Volume Discounts

If you want to buy electronic or paper versions of the Practical Unit Testing book for your team or company, then please contact me regarding the final price.
I have already bought TestNG book, should I also buy JUnit version?
Both books are very similar so I do not think that you need both. The difference is, that each of them uses different testing framework for all code examples. Also, because of some differences between JUnit and TestNG, some sections were changed. For example, in JUnit there is nothing about test-dependent methods.
I'm not Kent Beck, so I expect you to be a little hesitant about acquiring my books. Good! You should never believe what the marketing says! :) Anyway, I’m giving you the chance here to learn from other readers whether the books are worth your money and your time.
Sample Chapter
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. :)
Practical Unit Testing with TestNG and Mockito
In two hours of reading, I knew more of the usage of TestNG and Mockito than after several days of Web crawling. Review by Francis Galiegue, from mailing list
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. Franco Martinig, on Software Development Books site
Despite the Java/TestNG/Mockito orientation that the title might suggest, 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. From Franco Martinig's blog
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.
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. From review on site
[...] 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. Review by Tomasz Dziurko.
Bought only a few months after its publication (2012) I was delighted to find some very up-to-date content.
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. Review from Goodreads site
Practical Unit Testing with JUnit and Mockito
No reviews yet, but since the book is very similiar to the previous one, you could read what is written above.
Uh-oh, bugs happen, both in code and in books. Below, you will find the most prominent bugs.
BTW, if you buy the electronic version, you won't see them! :) Unfortunately, I cannot update the printed version so easily. :(
Practical Unit Testing with TestNG and Mockito
page is should be
section 3.8.2, page 48 Let us go back to the example of the Client and Address that were introduced in Section 3.9. Let us introduce now two simple Client and Address classes.
Practical Unit Testing with JUnit and Mockito
page is should be
section 6.15.2, page 181 Listing 6.51. updateUser() method Listing 6.51. assignPass() method
section 6.15.5, page 183 Listing 6.37 listing in the Section 6.11 section Listing 6.37 in the Section 6.11
section 8.9.2, page 243 8.9.2. Enhance the Custom Rule uh-oh, this exercise does not belong here! It was already included in 6.15.8!
section 9.8.2, page 273 private String state; private State state;
Questions regarding my books?
Feel free to e-mail me at
Możesz zapłacić za książki w złotówkach wpłacając na konto:

10 1950 0001 2006 0269 3956 0002
Tomasz Kaczanowski
Faktury wystawiam. Podaj proszę niezbędne dane.

Wersje papierowe

Możesz kupić bezpośrednio ode mnie papierowe książki z serii Practical Unit Testing. Zapłacisz nieco mniej niż na Amazonie - 100 PLN, i krócej poczekasz na przesyłkę.
Jeżeli jesteś zainteresowany, proszę o kontakt.

Wersje elektroniczne (do użytku prywatnego)

Cena książek z serii Practical Unit Testing w wersji elektronicznej wynosi 70 PLN. Dokonaj przelewu na podane powyżej konto, oraz napisz proszę maila z informacją że dokonałeś wpłaty zaznaczając czy chodzi o wersję TestNG czy JUnit.

Razem taniej!

Kupując książki z serii Practical Unit Testing razem z innymi moimi książkami - 1,2,3 Kanban lub Bad Tests, Good Tests - możesz liczyć na zniżki. Skontaktuj się ze mną proszę.

Zniżki przy zakupie większej ilości egzemplarzy

Jeżeli planujesz kupić kilka papierowych książek dla swojego zespołu lub firmy, wówczas obowiązują następujące zniżki:
liczba zakupionych książek procent zniżki
2-5 10%
6-10 20%
11-20 30%
20+ proszę o email
Jeżeli chciałbyś kupić elektroniczną wersję książek na potrzeby pracowników w firmie, proszę skontaktuj się ze mną podając w mailu liczbę osób jaka będzie korzystać z książki, oraz wersje (JUnit lub TestNG).