Practical Unit Testing with TestNG and Mockito
Practical Unit Testing with TestNG and Mockito is a book that is intended especially for those who would like to start unit testing their code, but are unsure about how to get started and what to focus on. It presents the unit testing domain with examples in the Java language using the TestNG and Mockito open source tools.
Tomek Kaczanowski says that his book is aimed at developers who want to produce high-quality, maintainable unit tests. The book provides a comprehensive vision of the unit testing activities from how to write unit tests to how to automate them or to enhance the quality of the testing scripts. The author doesn’t try to impose its own vision, but rather presents the different choices that you can or have to make and what are their consequences. You shouldn’t be afraid by the Java/TestNG/Mockito focus that the title might imply. This book is highly recommendable to all software developers interested in unit testing as it contains a large percentage of general unit testing knowledge that can be used independently of the Java language or the TestNG and Mockito tools.
Reference: “Practical Unit Testing with TestNG and Mockito”, Tomek Kaczanowski, 448 pages, IBSN 978-8393489305
Book Web Site: http://practicalunittesting.com/
The existence of a comprehensive and rigorous set of unit tests allows us to refactor code without any fear of breaking something: once all your classes are covered by unit tests, there are no areas of code left that “no one dares to touch”!
We should write our tests with the same attitude, trying to make them maintainable. Why? Because, as we have already discussed, they play a crucial role in supporting and documenting our production code.
A lot has been written already about code reviews, and it is not my goal to discuss their place and role in the software development process. Let me conclude with a short statement to the effect that code reviews are a must, because they help discover bugs, thus improving internal and external code quality, and because they spread knowledge of the code among different team members and help us improve by learning from each other. All of this is also true for code reviews performed on test code. In the absence of tools which could help us with validating the correctness, and assessing the quality, of our test code, code reviews are the only option for delivering test code of the highest quality.