Friday, 8 August 2014

5 Good Books to Learn Unit testing, JUnit and TDD for Java Developers

Unit testing is very, very important thing to learn adapt. I would say this is the single most practice in my book which differentiate a good programmer with a professional programmer. It's one way you can see how disciplined a programmer is? It's also the best way to write clean code; a code which can stand test of time, a code which is flexible enough to accommodate future changes and a code which you don't afraid while changing. Despite several efforts of promoting unit testing by programming community and emphasizing unit testing by many notable programmers, it's still one of the lacking practice. In my effort to encourage developers to do unit testing, I try to make it natural rather than a special thing. I have found that it's not that programmer doesn't want to test or they don't have time, it's because they don't really know how to unit test a non-trivial code. It's easy for someone to write unit test for palindrome or prime factor program, but when it comes to write unit test for a feature you are developing which involves database connection, threads, has dependency on other module and don't have a clear entry point, programmer's lost the zeal and enthusiasm. Since user or managers doesn't care about unit tests, programmer really don't push themselves to the level they usually do to make a functional code working. How do we solve this problem? How do you develop that code sense to write unit test? How do you decompose a big feature into small units which can be independently testable? Does it sounds like I am talking about Test driven development (TDD)? Well, Yes. Even if you don't follow TDD in it's true sense, it will help you to learn many tricks and techniques to unit test your code. In this article, I am going to share 5 books, which you would love to read, which will help you to learn unit testing and master the art or writing good tests. Unit testing and JUnit is synonymous in Java world, so most of these book will teach you unit testing using JUnit. This is good, because a sound knowledge of how JUnit works, and how you can use different JUnit annotations will encourage you to write more tests.

No comments:

Post a Comment