Pragmatic Unit Testing in Java with JUnit

  Author:    Dave Thomas, Andy Hunt, Andrew Hunt, David Thomas
  ISBN:    0974514012
  Sales Rank:    56726
  Published:    2003-09
  Publisher:    The Pragmatic Programmers
  # Pages:    159
  Binding:    Paperback
  Avg. Rating:    4.0 based on 12 reviews
  Used Offers:    13 from $14.46
  Amazon Price:    $19.77
  (Data above last updated:  2008-11-29 05:25:21 EST)
  
  
Sort customer reviews by:
  
Show All Reviews on Page      Hide All Reviews on Page
   
  
Pragmatic Unit Testing in Java with JUnit
  
Learn how to improve your Java coding skills using unit testing. Despite it's name, unit testing is really a coding technique, not a testing technique. Unit testing is done by programmers, for programmers. It's primarily for our benefit: we get improved confidence in our code, better ability to make deadlines, less time spent in the debugger, and less time beating on the code to make it work correctly. This book shows how to write tests, but more importantly, it goes where other books fear to tread and gives you concrete advice and examples of what to test--the common things that go wrong in all of our programs. Discover the tricky hiding places where bugs breed, and how to catch them using the freely available JUnit framework. It's easy to learn how to think of all the things in your code that are likely to break. We'll show you how with helpful mnemonics, summarized in a handy tip sheet (also available from our www.pragmaticprogrammer.com website) to help you remember all this stuff. With this book you will:
  • Write better code, and take less time to write it
  • Discover the tricky places where bugs breed
  • Learn how to think of all the things that could go wrong
  • Test individual pieces of code without having to include the whole project
  • Test effectively with the whole team
We'll also cover how to use Mock Objects for testing, how to write high quality test code, and how to use unit testing to improve your design skills. We'll show you frequent "gotchas"--along with the fixes--to save you time when problems come up. We'll show you how with helpful mnemonics, summarized in a handy tip sheet (also available from our www.pragmaticprogrammer.com website). But the best part is that you don't need a sweeping mandate to change your whole team or your whole company. You don't need to adopt Extreme Programming or Test-Driven Development, or change your development process in order to reap the proven benefits of unit testing. You can start unit testing, the pragmatic way, right away.
                  Reader Reviews 1 - 17 of 17                 
  
  
Review
Date
Review
Rating(5 High)
Review
Helpful
to:
Customer Review Reviewer
Info
Permanent
Link
Reader Reviews Below Sorted by Newest First
06-05-07 1 0\1
(Hide Review...)  Sorely in Need of Update
Reviewer Permalink
Buyer beware. This book does not reflect the many changes to JUnit implemented in version 4. I found it to be a very good book when it came out four years ago however.
(Review Data Last Updated: 2008-07-15 07:20:04 EST)
06-04-07 1 0\2
(Hide Review...)  Sorely in Need of Update
Reviewer Permalink
Buyer beware. This book does not reflect the many changes to JUnit implemented in version 4. I found it to be a very good book when it came out four years ago however.
(Review Data Last Updated: 2008-11-30 06:25:25 EST)
02-17-07 4 (NA)
(Hide Review...)  good
Reviewer Permalink
pragmatic Unit testing in java save a lot of time to debug java code.
(Review Data Last Updated: 2007-06-27 20:47:40 EST)
02-02-07 4 (NA)
(Hide Review...)  JUnit Testing
Reviewer Permalink
JUnit Testing can really save you a lot of time debugging. This book provides a various way to work with JUnit.
(Review Data Last Updated: 2007-06-27 20:47:40 EST)
02-01-07 4 (NA)
(Hide Review...)  JUnit Testing
Reviewer Permalink
JUnit Testing can really save you a lot of time debugging. This book provides a various way to work with JUnit.
(Review Data Last Updated: 2007-02-17 16:21:05 EST)
08-16-06 5 (NA)
(Hide Review...)  Great JUnit Starter Kit
Reviewer Permalink
This is another fine book from the "Pragmatic Programmer" series. If you are doing Java development, but haven't gotten into unit testing yet, this is a great place to start. The book is a quick read - I made it through in two days. The book gives background on why unit testing is important and then tells you how to go about doing it with JUnit. The book has practical advice for the kinds of things to include in unit tests while it finishes with design considerations for make code easier to test. To get the most out of the book, you need to download the code from the author's web site and work through the exercises. It is great how they have taken a critical topic and made it extremely accessible. I highly recommend it.
(Review Data Last Updated: 2007-06-27 20:47:40 EST)
08-15-06 5 (NA)
(Hide Review...)  Great JUnit Starter Kit
Reviewer Permalink
This is another fine book from the "Pragmatic Programmer" series. If you are doing Java development, but haven't gotten into unit testing yet, this is a great place to start. The book is a quick read - I made it through in two days. The book gives background on why unit testing is important and then tells you how to go about doing it with JUnit. The book has practical advice for the kinds of things to include in unit tests while it finishes with design considerations for make code easier to test. To get the most out of the book, you need to download the code from the author's web site and work through the exercises. It is great how they have taken a critical topic and made it extremely accessible. I highly recommend it.
(Review Data Last Updated: 2007-02-01 16:01:20 EST)
07-28-06 4 (NA)
(Hide Review...)  Good introduction to unit testing
Reviewer Permalink
This book is very good for a beginner to unit testing. I like the simple explanation of the different types of unit testing that must be done. This really helps a beginner to make sure that the tests are comprehensive.

Also it clarifies the intention behind use of mock objects. I would use the concepts in this book as a checklist to make sure the tests are written to cover all types of problems.

I gave 4 star only because it contains toy examples and does not go into too much detail on this very important topic. JUnit Recipes contains more realistic examples.
(Review Data Last Updated: 2007-06-23 10:11:19 EST)
07-27-06 4 (NA)
(Hide Review...)  Good introduction to unit testing
Reviewer Permalink
This book is very good for a beginner to unit testing. I like the simple explanation of the different types of unit testing that must be done. This really helps a beginner to make sure that the tests are comprehensive.

Also it clarifies the intention behind use of mock objects. I would use the concepts in this book as a checklist to make sure the tests are written to cover all types of problems.

I gave 4 star only because it contains toy examples and does not go into too much detail on this very important topic. JUnit Recipes contains more realistic examples.
(Review Data Last Updated: 2006-08-16 09:57:16 EST)
10-18-05 2 15\17
(Hide Review...)  a shallow introduction to a deep subject
Reviewer Permalink
When I decided to learn about JUnit I picked up two books: this one and "JUnit Recipes" by Rainsberger. The differences were immediately obvious. "Pragmatic Unit Testing" is a reasonable choice if your goal is to simply learn something about JUnit (e.g., you are a high school or college student taking a couple of programming courses). On the other hand, if your goal is to actually make use of JUnit to help you produce code that actually does something, you will quickly drop this book and turn to some other source of information.

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.
(Review Data Last Updated: 2007-06-27 20:47:40 EST)
09-02-05 3 3\6
(Hide Review...)  A good pamphlet on JUnit
Reviewer Permalink
This book serves as a good introduction to JUnit for those who haven't had exposure to it before. However, it's fairly shallow, and those willing to read through the JUnit FAQ and a few articles online will probably get just as much information. The only real advantage to the book is its well-organized presentation of the material. For those seeking more depth, you should look elsewhere.
(Review Data Last Updated: 2006-06-02 12:24:49 EST)
03-03-05 5 5\6
(Hide Review...)  This should be required reading for new Java programmers
Reviewer Permalink
Pragmatic Unit Testing is one of those books that you only find once in a great while: concise, readable, practical, and applicable to everyday work tasks. There are a number of test frameworks for Java, a number of them based on JUnit. This is both good and bad: good, because JUnit is an effective, easy to use framework, and bad, because the documentation that comes with JUnit is horrible. This book is the documentation that JUnit SHOULD come with. Although quite simple in nature, this book provides guidelines not only for using JUnit, but concepts for planning effective Unit tests as well. I particularly like the examples and exercises the authors included with the book, as I learn better by doing them and seeing the results myself.

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.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
10-21-04 5 4\4
(Hide Review...)  bridging the gap
Reviewer Permalink
Unit Testing is one of those widely accepted good practices that is not always well applied. This book helps to bridge the gap between what should be done and what is done.

While JUnit and Mock Objects are introduced in the text, the main focus is on developing insight into the philosophy of pragmatic unit testing. Most developers have a vague understanding of the why and how, but what do their results really mean? Are they sufficient to determine that the code is correct? How does the developer know?

With anecdotes and clear examples, the authors help to clear the fog. Just as important, they dispel many of the testing myths and explode the excuses that are offered for not unit testing. Resistance will frequently come developers, but also from management thinking that developing test code will add time to the project instead of saving it.

A side-effect of developing unit tests is that they add another layer of code that must be managed. Do you need tests for your test? Where does it end? Again the pragmatic programmers provide poignant pointers to managing the tests themselves.

One of the pragmatic programmer commandments must be "Be brief". In less than 160 pages, this slim volume covers a lot of ground. For a project technical lead, several copies for your team to read may be a solid investment. Be sure to make a poster-sized version of the "Pragmatic Unit Testing: Summary" page from the book for the wall behind your desk.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
09-12-04 5 3\3
(Hide Review...)  an excellent introduction
Reviewer Permalink
(The following is an excerpt of a review of "The Pragmatic Starter Kit" I posted at JavaRanch.)

"Pragmatic Unit Testing - In Java with JUnit" - the second volume in the three part "The Pragmatic Starter Kit" series" - from authors, Andrew Hunt and David Thomas, is an excellent introduction to the practice of unit testing - proving that a piece of code does what the developer intended it to do. If you're a new developer, hopefully you've asked yourself and others questions about how to establish that your code really works, how to feel confident that it keeps working after scores of changes have been made, what types of common problems and bugs should you be looking for, where are these problems likely to be, and what makes a good test. While answering those questions, this book also introduces the practice of testing with Mock Objects, how to organize the test code in a project, how to better design code for testability, and how to make use of JUnit for running all these tests. I'd recommend this book as a strong introduction to any developer new to or uncertain about the art of unit testing.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
08-18-04 3 7\7
(Hide Review...)  A good introduction but not Reference Shelf material
Reviewer Permalink
Pragmatic Unit Testing is another outing for the "Pragmatic" brand. This time the authors apply their characteristic humour and collection of acronyms to unit testing, specifically as it applies to Java and using the JUnit software package.

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.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
07-29-04 5 7\9
(Hide Review...)  Great Description of Unit Testing
Reviewer Permalink
There has been a resurgent interest amongst developers in unit
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
test. 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.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
07-28-04 5 11\11
(Hide Review...)  A cornucopia of wisdom
Reviewer Permalink
Refusing to rest on their laurels from their 1999 success The Pragmatic Programmer, Andrew Hunt and David Thomas are back with a vengeance. They've taken a step back from their previous title to write The Pragmatic Starter Kit, billed as a prequel to The Pragmatic Programmer. The Pragmatic Starter Kit, meant to lay the foundation for a pragmatic programmer, consists of three titles: Pragmatic Version Control, Pragmatic Unit Testing, and Pragmatic Automation. Together, these titles show how to set up a sound development infrastructure, and educate as to fundamental practices, tools, and philosophies which may be used to enhance productivity within this infrastructure.

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.
(Review Data Last Updated: 2006-07-07 09:43:36 EST)
  
                  Reader Reviews 1 - 17 of 17                 
  
  
  
  
  
  

Because the data used to generate this site come from outside sources, VeryWellSaid.com cannot guarantee the completeness or accuracy of the data.
Search VeryWellSaid™
Google
Web VeryWellSaid™
New subjects are added every week.
View Subjects Below by:
* Top Selling
 (click category name, left)
* Top-Rated Top Sellers
 (click 'Top Rated', right)
In the news...  
Dubai\UAE Top Rated
Influenza\Bird Flu Top Rated
Iraq Top Rated
Supreme Court Top Rated
All Books Top Rated
Arts Top Rated
Photography Top Rated
Digital Photography Top Rated
Digital Cameras Top Rated
Biography Top Rated
Business Top Rated
Management Top Rated
Marketing Top Rated
Sales Top Rated
Stocks Top Rated
Bonds Top Rated
Real Estate Top Rated
Trading Top Rated
Commodities Trading Top Rated
Time Management Top Rated
Starting A Business Top Rated
Children's Top Rated
Comics Top Rated
Computers Top Rated
PC Top Rated
Mac Top Rated
Programming Top Rated
Design Patterns Top Rated
.Net Top Rated
C# Top Rated
Vb.Net Top Rated
Asp.Net Top Rated
Java Top Rated
Python Top Rated
PHP Top Rated
Perl Top Rated
Javascript Top Rated
Ajax Top Rated
CSS Top Rated
Open Source Top Rated
SQL Top Rated
Databases Top Rated
Oracle Top Rated
MySql Top Rated
Sql Server Top Rated
IIS Top Rated
Apache Top Rated
Linux Top Rated
Windows Server Top Rated
Project Management Top Rated
HTML Top Rated
UML Top Rated
IT Certifications Top Rated
Cisco Certifications Top Rated
MCSE Top Rated
MCSD Top Rated
Cooking Top Rated
Italian Cooking Top Rated
Vegetarian Cooking Top Rated
Wine Top Rated
Engineering Top Rated
Entertainment Top Rated
Health Top Rated
Nutrition Top Rated
Dieting Top Rated
Sex Top Rated
History Top Rated
Military History Top Rated
British History Top Rated
Middle East History Top Rated
Land Battles Top Rated
Naval Warfare Top Rated
Air Warfare Top Rated
9/11 Top Rated
Terrorism Top Rated
Home Top Rated
Mortgage\Home Equity Loan Top Rated
Cars Top Rated
Car Buying Top Rated
Sports Cars Top Rated
Cat Top Rated
Humor Top Rated
Horror Top Rated
Law Top Rated
IP Law Top Rated
Legal History Top Rated
Fiction Top Rated
Oprah's Book Club Top Rated
Medicine Top Rated
Cancer Top Rated
Stroke Top Rated
Heart Disease Top Rated
Fertility Top Rated
Diabetes Top Rated
Pharmacology Top Rated
Back Problems Top Rated
Menopause Top Rated
Thyroid Top Rated
Pain Top Rated
Organic Chemistry Top Rated
Immune System Top Rated
Mystery Top Rated
Nonfiction Top Rated
Outdoors Top Rated
Running Top Rated
Radio Control Models Top Rated
Guns Top Rated
Parenting Top Rated
Divorce Top Rated
Professional Top Rated
Reference Top Rated
Religion Top Rated
Romance Top Rated
Science Top Rated
Physics Top Rated
Chemistry Top Rated
Astronomy Top Rated
Psychology Top Rated
Science Fiction Top Rated
Sports Top Rated
Teens Top Rated
Travel Top Rated
USA Top Rated
Europe Top Rated
France Top Rated
Italy Top Rated
England Top Rated
China Top Rated
All Books Arts Biography Click Here For An A-Z Index Of All 213 Best-Seller Subjects Business Children's Comics
Computers Cooking Engineering Entertainment Health History Home Horror Humor Law Fiction Medicine Mystery
Nonfiction Outdoors Parenting Professional Reference Religion Romance Science Sci-Fi Sports Teens Travel
In Association with Amazon.com

Cache miss
(not cached)