Unit Testing in Java

Book description

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.
  • 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.

Table of contents

  1. Cover image
  2. Title page
  3. Table of Contents
  4. Copyright
  5. Foreword
  6. Foreword
  7. Preface
  8. Part I: Basic Techniques
    1. Chapter 1: Introduction
      1. 1.1 Important Terms
      2. 1.2 XP Testing
      3. 1.3 Classic Testing
      4. 1.4 Test-First Development–A Brief Definition
      5. 1.5 Java Only–Or Other Coffee?
      6. 1.6 Objectives of This Book
      7. 1.7 Organization of This Book
      8. 1.8 Conventions in This Book
      9. 1.9 Web Site to This Book
    2. Chapter 2: Automating Unit Tests
      1. 2.1 What Do We Want to Automate?
      2. 2.2 Requirements for an Automation Framework
      3. 2.3 JUnit
      4. 2.4 Summary
    3. Chapter 3: Basic Steps of the Test-First Approach
      1. 3.1 Step by Step
      2. 3.2 Dependencies
      3. 3.3 Organizing and Running Tests
      4. 3.4 Summary
    4. Chapter 4: Test Ideas and Heuristics
      1. 4.1 Reworking Single Tests
      2. 4.2 Black and White Boxes
      3. 4.3 Testing the Typical Functionality
      4. 4.4 Threshold Values and Equivalence Classes
      5. 4.5 Error Cases and Exceptions
      6. 4.6 Object Interactions
      7. 4.7 Design by Contract
      8. 4.8 More Ideas to Find Test Cases
      9. 4.9 Refactoring Code and Tests
      10. 4.10 Summary
    5. Chapter 5: The Inner Life of a Test Framework
      1. 5.1 Statics
      2. 5.2 The Life Cycle of a Test Suite
      3. 5.3 Project-Specific Expansions
      4. 5.4 Summary
    6. Chapter 6: Dummy and Mock Objects for Independence
      1. 6.1 Little Dummies
      2. 6.2 Weltering in Technical Terms
      3. 6.3 Big Dummies
      4. 6.4 Extending Our Mansion
      5. 6.5 Endoscopic Testing
      6. 6.6 Mock Objects from the Assembly Line
      7. 6.7 Testing Threshold Values and Exceptions
      8. 6.8 How Does the Test Get to the Mock?
      9. 6.9 Evil Singletons
      10. 6.10 Lightweight and Heavyweight Mocks
      11. 6.11 File Dummies
      12. 6.12 More Typical Mock Objects
      13. 6.13 External Components
      14. 6.14 The Pros and Cons
      15. 6.15 Summary
    7. Chapter 7: Inheritance and Polymorphism
      1. 7.1 Inheritance
      2. 7.2 Polymorphism
      3. 7.3 Summary
    8. Chapter 8: How Much Is Enough?
      1. 8.1 The XP Rule
      2. 8.2 Clear Answers to Clear Questions
      3. 8.3 Test Coverage
      4. 8.4 Summary
  9. Part II: Advanced Topics
    1. Chapter 9: Persistent Objects
      1. 9.1 Abstract Persistence Interface
      2. 9.2 Persistent Dummy
      3. 9.3 Designing a Database Interface
      4. 9.4 Testing the “Right” Persistence
      5. 9.5 Interaction between Persistence Layer and Client
      6. 9.6 Summary
    2. Chapter 10: Concurrent Programs
      1. 10.1 Problems Using Threads
      2. 10.2 Testing Asynchronous Services
      3. 10.3 Testing for Synchronization
      4. 10.4 Summary
    3. Chapter 11: Distributed Applications
      1. 11.1 RMI
      2. 11.2 Enterprise JavaBeans
      3. 11.3 Summary
    4. Chapter 12: Web Applications
      1. 12.1 Functional Tests
      2. 12.2 Testing on the Server
      3. 12.3 Testing with Dummies
      4. 12.4 Separating the Servlet API from the Servlet Logic
      5. 12.5 Testing the HTML Generation
      6. 12.6 Summary
    5. Chapter 13: Graphical User Interfaces
      1. 13.1 The Direct Way
      2. 13.2 Short Detours
      3. 13.3 Summary
    6. Chapter 14: The Role of Unit Tests in the Software Process
      1. 14.1 Activities in the Defined Software Process
      2. 14.2 Process Types and Testing Strategies
      3. 14.3 Costs and Benefits of Automated Unit Tests
      4. 14.4 Commercial Process Models
      5. 14.5 Will Automated Unit Tests Fit in My Process?
    7. Chapter 15: Loose Ends and Opportunities
      1. 15.1 Unit Testing for Existing Software
      2. 15.2 Introducing Unit Tests to the Development Team
      3. 15.3 What’s Missing?
  10. Part III: Appendices
    1. Appendix A: Notes to JUnit
    2. Appendix B: Unit Tests with Other Programming Languages
  11. Glossary
  12. Bibliography and List of References
  13. Index
  14. Inside Back Cover

Product information

  • Title: Unit Testing in Java
  • Author(s): Johannes Link, Peter Fröhlich
  • Release date: June 2003
  • Publisher(s): Morgan Kaufmann
  • ISBN: 9780080520179