JUnit in Action
Second Edition of this book is available

Vincent Massol with Ted Husted

2003 | 384 pages | B&W
ISBN: 1930110995

Out of Print $39.95 Softbound print + PDF eBook
$31.99 eBook edition (PDF only)



Developers in the know are switching to a new testing strategy - unit testing - which interleaves coding and testing in an integrated way. This has proven to be a powerful combination that results in better designed software with fewer defects and faster delivery cycles.

JUnit in Action shows you how to benefit from this strategy using the popular open source testing framework, JUnit. It's a no fluff discussion of unit testing techniques and best practices. It gives examples of tough situations such as how to unit test EJBs, database applications, JSPs and Taglibs. It discusses unit testing of J2EE applications, and shows how to test in automated builds.



If you have questions about JUnit in Action, please use the following mailing lists or forums:

Please note that for mailing lists, you'll need to subscribe to the list before being able to post messages.


"There are a lot of poorly written books out there. Some are just plain wrong and others just barely manage to solve the problem, but don't go much further than that. With a number of the Manning books I can see myself start to think differently about the problems and so I end up being a better developer. The JUnit in Action book was like that for me. At first it bothered me that I was changing my code in order to test it, but then I started seeing that the changes made the code better overall. Now my code is littered with factory methods and similar structures."

"You guys are doing good stuff."
-- Joshua Smith, a reader

"The book is liberally sprinkled with JUnit best practices that every reader should take to heart. The examples are clear and real world. The author addresses the complex issues of unit testing EJBs, and web apps head on. He does not shy away from the real issues that come with testing these kinds of applications.

"Do you write code? Do you develop software? Do you think about writing software? Then you need this book. This book should become your friend, your companion, a part of your family. Even though the title is JUnit in Action, many of the topics in this book apply to the other xUnit frameworks."

"Vincent Massol takes the reader on a journey though the JUnit framework, the Cactus extension, Ant, and Mock Objects. He explains each topic in detail and leaves me with a good understanding of the topics. The book is liberally sprinkled with JUnit best practices that every reader should take to heart. The examples are clear and real world. The author addresses the complex issues of unit testing EJBs, and web apps head on. He does not shy away from the real issues that come with testing these kinds of applications."

"The author also writes about how to integrate your unit testing into you build and configuration management systems. Personally, this is an area that most projects I have worked on needed the most help. It is all fine to have unit tests, but if they are not automated and part of your build process, there value is significantly decreased. Vincent deals with the complex problems of automating deployment of web apps and EJB components and testing them with your build system."

"Another area that gets much needed attention is test database applications. The author presents a great chapter and example of using DBUnit and how to address the typical problems associated with database testing."

"One flaw in the book has to be the snapshots of the JUnit GUI results screen. The author tells me the bar is green, but as hard as I squint it still looks dark grey."

"To sum up, I think every Java software developer needs this book on their shelf. I am currently doing C# and I am happy that I have this book on my shelf as many of the ideas and best practices translate directly into NUnit testing."
-- Wade Matveyenko, a reader


Vincent Massol is Chief Technology Officer of Pivolis which specializes in agile offshore software development. Vince is an active member of the Maven, Gump and MockObjects development teams and the creator of the Jakarta Cactus testing framework. He lives in the City of Light, Paris, France.

Ted Husted is the lead author of Struts in Action, published by Manning.


Two sample chapters of JUnit in Action are available in PDF format. You need Adobe's free Acrobat Reader software to view it. You may download Acrobat Reader here.

Download Chapter 3

Download Chapter 7


"I would definitely recommend JUnit in Action for anyone interested in testing their code...It is a book that you will find flows nicely, and offers a great mix of technology theory, and how to put it all to practice."
-- TheServerSide.com

"An essential guide for intermediate level Java programmers who want to learn how to build J2EE applications properly...clear, simple and fun ... the best I have seen thus far."

"Besides introducing you to the JUnit framework, you will learn how to create good software tests and see how JUnit can be used to express tried and true design patterns. The book actually goes into detail about using mock objects and stubs, further expanding your understanding of basic software designs...I highly recommend it."
-- Killersites.com

"JUnit in Action is the definitive how-to manual for unit testing J2EE components. Pick up one of the other books if you're looking for something more motivational, but when you're ready to sit down and bang out some code, you'll want this book at your side."
-- JavaRanch.com

"Not a JUnit tutorial, it covers JUnit in depth. It also explains the importance of JUnit in the context of software development process. This well edited book is highly recommended both for the beginner and advanced users of JUnit."
-- Denver JUG


Source code for JUnit in Action is contained in a single ZIP file. Free unzip programs can be found at www.download.com.

junitbook 1.0 -- 3.8 MB

The JUnit in Action source code has been donated to the Open Source community under an Apache Public License. It is under community development on SourceForge.