- Amazon Student members save an additional 10% on Textbooks with promo code TEXTBOOK10. Enter code TEXTBOOK10 at checkout. Here's how (restrictions apply)
Pragmatic Unit Testing in Java with Junit Paperback – Sep 11 2003
Special Offers and Product Promotions
Customers Who Bought This Item Also Bought
No Kindle device required. Download one of the Free Kindle apps to start reading Kindle books on your smartphone, tablet, and computer.
To get the free app, enter your e-mail address or mobile phone number.
About the Author
Andy Hunt is a programmer turned consultant, author and publisher. He co-authored the best-selling book “The Pragmatic Programmer”, was one of the 17 founders of the Agile Alliance, and co-founded the Pragmatic Bookshelf, publishing award-winning and critically acclaimed books for software developers.
Most Helpful Customer Reviews on Amazon.com (beta)
A quick look at the index or table of contents highlights the problem with this book. Think about some of the constructs in your code: interfaces, SQL databases, XML, J2EE apps, web servers, etc. None of these topics are listed because this book doesnt give you any input on how to construct JUnit tests for any of these situations. For example, what's the best way to test when multiple classes implement the same interface? No help here.
The books is best used as a quick intro to testing for novice Java programmers. For anyone doing serious programming I suggest the Rainsberger book. Thats the one I keep on my desk close at hand. "Pragmatic Unit Testing" now resides in a box down in my basement.
The book gives a general introduction to the whys and wherefores of unit testing and then uses a good example to introduce JUnit as a mechanism for carrying out these tests. This is followed by various chapters that look into what you should test and when and where, etc. In this respect it covers much of the ground on unit testing and does it well but the truth is that there isn't all that much to cover; to the extent that the authors can even provide a one page at-a-glance summary of all their main points at the back of the book. This is fine and as an introductory text I would recommend the book.
On the other hand, there are a number of areas in unit testing that always present problems for developers. For instance:
How should private methods be tested? This is mentioned in passing but not really addressed.
Where should tests be stored? Some options are presented but their advantages and disadvantages barely mentioned.
How can systems such as databases or networks be simulated for test purposes? There is a short chapter on simple Mock Objects but after presenting a small example they conclude "and that's all there is to mock objects" and the rest of the chapter barely covers anything more.
In summary, the book is a good (if verbose) introduction for beginners but is of limited value for those who are already familiar with JUnit and are looking for a book that tackles the more difficult areas.
Pragmatic Unit Testing, the second volume of The Pragmatic Starter Kit, teaches the developer to code smartly by practicing a regime of disciplined unit testing. Hunt and Thomas begin by convincing the reader just why it is we must write unit tests, and then quickly debunk the most common excuses developers use for not testing. Now that we are suitably convinced, the authors go on to explain how to plan and write unit tests, how to work with the JUnit framework, and how to use mock objects.
Most books on this subject don't really go too far beyond how to write unit tests. Where this book stands head and shoulders above the rest though, is the great depth the book goes into showing us exactly what tests need to be written. Through a series of helpful mnemonics, the reader is taught exactly what to test, how to correctly test boundary conditions, and what the properties of good tests are. We are also given general testing principles to keep in mind, as well as questions to ask ourselves about our code while testing. The concepts given herein are invaluable, and if the book ended with just this, it would be well worth the money.
The book doesn't stop there however. The authors offer excellent advice for integrating unit testing within the scope of a project in a team environment, and we are given a look at how unit testing can influence design. Exercises are presented to help the reader practice key concepts throughout the book.
There are a couple of things that this book isn't. This book is not a treatise on how to unit test specific components in an application. As stated previously, this book is less about how to test specific components, and more about what tests should be written in the first place. This book also does not overtly espouse any particular process. Extreme programming and test-driven development are certainly mentioned, but they are not championed above other processes.
This book is concise, weighing in at around 159 pages. The book is a very quick and pleasant read. It is appropriate for the novice as well as the developer who's been around the block a couple of times. If you write unit tests, and particularly if you are new to the game, this book is a cornucopia of wisdom. Pragmatic Unit Testing is to the practice of unit testing, what Joshua Bloch's Effective Java is to the Java programming language. That's certainly high praise indeed.
If you're not familiar with Unit testing or skeptical of the results, read this book and give it a fair try. You'll never program the same way again.
testing, mostly spurred on by Extreme Programming, test-driven
development and the JUnit testing harness. But most of the discussion
has been on how tests can shape design, rather than on how tests can
<i>test.</i> This book does the best job of describing how JUnit-style unit
tests can actually be used for testing. The book is available in two
flavors: one in Java for JUnit and one in C# for NUnit.
Look for similar items by category
- Books > Computers & Technology > Computer Science > Information Theory
- Books > Computers & Technology > Computer Science > Software Engineering > Information Systems
- Books > Computers & Technology > Operating Systems
- Books > Computers & Technology > Programming > Java
- Books > Computers & Technology > Programming > Languages & Tools
- Books > Computers & Technology > Programming > Software Design, Testing & Engineering > Object-Oriented Design
- Books > Computers & Technology > Programming > Software Design, Testing & Engineering > Software Development
- Books > Computers & Technology > Programming > Software Design, Testing & Engineering > Testing
- Books > Computers & Technology > Software
- Books > Textbooks > Computer Science & Information Systems > Computer Science
- Books > Textbooks > Computer Science & Information Systems > Object-Oriented Software Design
- Books > Textbooks > Computer Science & Information Systems > Operating Systems
- Books > Textbooks > Computer Science & Information Systems > Programming Languages
- Books > Textbooks > Computer Science & Information Systems > Software Design & Engineering