Flylib.com

Books Software

 
 
 

Copyright

     

Copyright 2005 O'Reilly Media, Inc. All rights reserved.

Printed in the United States of America.

Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc. Unit Test Frameworks , the image of the image of a Norway rat, and related trade dress are trademarks of O'Reilly Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

     

Preface

This book presents a comprehensive review of the xUnit family of unit test frameworks, including their usage, architecture, and theory. We begin by building a simple unit test framework from the ground up. The xUnit architecture is presented, using the JUnit framework as the reference implementation of xUnit. We progressively build an example application to demonstrate common practices and patterns of unit test development. Several popular versions of xUnit, including JUnit, CppUnit, NUnit, PyUnit, and XMLUnit, are covered in detail. Detailed class references are provided for JUnit and CppUnit as appendixes.

As a software development methodology, unit testing incorporates many rules and guidelines. However, writing unit tests is an art, not a science. Once you are familiar with the unit test driven approach to development, rigidly following its rules is optional. The true value of unit testing is in the focus on low-level software quality it gives developers, rather than as a formal process.

     

Audience

This book is intended for software developers, technical managers, and quality assurance staff who are learning about unit testing and agile development. Agile development is the wave of the future in software engineering, and many technical organizations are adopting it. Using unit test frameworks to enable test driven development is a key to becoming agile.

     

Contents of This Book

Here is a summary of the topics covered in each chapter and appendix:


Chapter 1

An overview that explains what unit test frameworks are and how they are used.


Chapter 2

A tutorial that creates a simple Java test framework. This provides the fundamentals of how unit test frameworks work. Appendix A contains the C++ version of this simple framework tutorial.


Chapter 3

A review of xUnit, using JUnit as a reference implementation to demonstrate basic xUnit architecture and usage.


Chapter 4

An overview of writing unit tests. This offers a more detailed discussion of different types of unit tests and patterns of unit test development.


Chapter 5

A discussion of unit testing of GUI applications. This chapter explains how to build and test GUI objects following the smart object model.


Chapter 6

A description of the details of the usage and architecture of JUnit for Java.


Chapter 7

A description of the details of the usage and architecture of CppUnit for C++.


Chapter 8

A description of the details of the usage and architecture for NUnit for .NET.


Chapter 9

A description of the details of the usage and architecture of PyUnit for Python.


Chapter 10

A description of the details of the usage and architecture of XMLUnit for XML.


Chapter 11

A list of additional resources for unit test frameworks and related topics.


Appendix A

The C++ version of the simple unit test framework from Chapter 2.


Appendix B

A detailed class reference for JUnit's key package junit.framework.


Appendix C

A detailed class reference for CppUnit.


Glossary

A list of definitions for important technical terms used in this book.