Unit Testing in Java

1st Edition

How Tests Drive the Code

Print ISBN: 9781558608689
eBook ISBN: 9780080520179
Imprint: Morgan Kaufmann
Published Date: 20th May 2003
Page Count: 376
45.95 + applicable tax
36.99 + applicable tax
5500.00 + applicable tax
60.95 + applicable tax
Compatible Not compatible
VitalSource PC, Mac, iPhone & iPad Amazon Kindle eReader
ePub & PDF Apple & PC desktop. Mobile devices (Apple & Android) Amazon Kindle eReader
Mobi Amazon Kindle eReader Anything else

Institutional Access


Software testing is indispensable and is one of the most discussed topics in software development today. Many companies address this issue by assigning a dedicated software testing phase towards the end of their development cycle. However, quality cannot be tested into a buggy application. Early and continuous unit testing has been shown to be crucial for high quality software and low defect rates. Yet current books on testing ignore the developer's point of view and give little guidance on how to bring the overwhelming amount of testing theory into practice. Unit Testing in Java represents a practical introduction to unit testing for software developers. It introduces the basic test-first approach and then discusses a large number of special issues and problem cases. The book instructs developers through each step and motivates them to explore further.

Key Features

Shows how the discovery and avoidance of software errors is a demanding and creative activity in its own right and can build confidence early in a project. Demonstrates how automated tests can detect the unwanted effects of small changes in code within the entire system. Discusses how testing works with persistency, concurrency, distribution, and web applications. Includes a discussion of testing with C++ and Smalltalk.


Software developers and Java programmers.

Table of Contents

Part 1: Basic Techniques 1 Introduction 1.1 Important Terms 1.2 XP Testing 1.3 Classic Testing 1.4 "Test-First Development" - A Brief Definition 1.5 Java Only - Or Other Coffee? 1.6 Objectives of This Book 1.7 Organization of This Book 1.8 Conventions in This Book 1.9 Web Site to This Book

2 Automating Unit Tests 2.1 What Do We Want to Automate? 2.2 Requirements to an Automation Framework 2.3 Junit 2.4 Summary

3 Basic Steps of the Test-first Approach 3.1 Step by Step 3.2 Dependencies 3.3 Organizing and Running Tests 3.4 Summary

4 Test Ideas and Heuristics 4.1 Reworking Single Tests 4.2 Black and White Boxes 4.3 Testing the Typical Functionality 4.4 Threshold Values and Equivalence Classes 4.5 Error Cases and Exceptions 4.6 Object Interactions 4.7 Design by Contract 4.8 More Ideas to Find Test Cases 4.9 Refactoring Code and Tests 4.10 Summary

5 The Inner Life of a Test Framework 5.1 Statics 5.2 The Life Cycle of a Test Suite 5.3 Project-specific Expansions 5.4 Summary

6 Dummy and Mock Objects for Independence 6.1 Little Dummies 6.2 Weltering in Technical Terms 6.3 Big Dummies 6.4 Extending our Mansion 6.5 Endoscopic Testing 6.6 Mock Objects from the Assembly Line 6.7 Testing Threshold Values and Exceptions 6.8 How Does the Test Get to the Mock? 6.9 Evil Singletons 6.10 Lightweight a


No. of pages:
© Morgan Kaufmann 2004
Morgan Kaufmann
eBook ISBN:
Paperback ISBN:


I haven't found a high quality book like this on JUnit. Unit Testing in Java does for unit testing what Alan Cooper's About Face did for usability: it makes unit testing mainstream among developers.—Frank Cohen, Push to Test