Effective Unit Testing — A must-read Book for Programmers

JAVING
Javarevisited
Published in
4 min readJun 17, 2020

--

Want to learn about the art of unit testing, why it is so important and what are all the tools involved in building great unit tests? This book can help

image_credit — Effective Unit Testing Book

The Effective Unit Testing book is not new. It was published years ago. I consider it a very important book in my career. Unit testing is in my opinion the cornerstone of modern software development. Many authors and big influential figures of the software scene have always acknowledged the importance of unit testing. I read it time ago and I thought to do a little review and explain why I think this is an important book for programmers at all levels of seniority.

You will not appreciate the importance of unit tests until you begging working and debugging a large untested legacy code-base. Unit testing is a fantastic tool that helps the programmer reduce the risk of encountering bugs and it also pays off by improving overall productivity boosting the quality of the code that is written.

This book will transmit you the huge importance of having tests for the code you write. And also you will learn something that many times is disregarded and that is to not just write good unit tests, but also to write them in a way that are readable and what is more important maintainable.

It’s a beautiful, brief and very well explained book that will not leave you indifferent.

During my career I have seen code bases that were very hard to understand and test. Many of the tools and techniques I learned from this book have helped me. Have you ever dealt with an intermittent/flaky test? Have you ever had to simulate a slow responding system? Or have you ever thought that the code you are looking at is really hard to test? This are some of the questions that you will be able to give answers to by learning about Effective Unit Testing.

One of the chapters I enjoyed most on this book was Chapter 4. It was fully dedicated to readability in unit tests. You would not believe how many programmers don’t know how to write readable unit tests. Is not just the structure and what is that is being tested, but also how it is expressed refactored and how the testing constructs are utilised in a way that the readability is facilitated.

All chapters in this book are really good but I particularly enjoyed Chapter 4 and Chapter 5. The deep dive into the topic of maintainability in Chapter 5 is a must read for any java programmer.

source: Effective Unit Testing Chapter 5

Can you spot the lack of quality in which the two above tests are written? They do have different duplication. Refactoring is something that is not just for production code, it is also for test code. And it is essential to learn to maintain your tests since the more features you add to your code base the more important will be the topic of maintainability.

Poorly written unit tests can cost you hours of work just to add new trivial features into your software. Well crafted unit tests are as important as well crafted production code.

Probably this book is one of it’s kind. You will find many great books that will talk about unit testing but most of them they do talk about the topic of unit testing as a side dish, it is always within the context of refactoring or clean coding or TDD. That’s great but Effective Unit Testing focuses so much on the aspects of quality an goes into so much detail into the ins and outs of unit testing that makes it a great book in every programmers bookshelves.

Manning is a great editorial and the book in my opinion is priced very modestly. It is easy to read, the examples are very clear and insightful. It is a brief book given the amount of detail it goes into and what you learn from it can be applied on your daily work almost immediately. When I read this book some years ago I remember always taking it with me to work and use it as reference since there was so much useful stuff on it that I was using on daily basis.

Have you read Effective Unit Testing? What did you think about it? Please let me know your thoughts in the comments section.

--

--

JAVING
Javarevisited

The present continuous form of “to program in Java”.