Growing Object-Oriented Software Guided by Tests

Table of Contents

  1. Foreword
  2. Preface
  3. Acknowledgments
  4. About the Authors
  5. Part I: Introduction
    1. Chapter 1: What Is the Point of Test-Driven Development?
      1. Software Development as a Learning Process
      2. Feedback Is the Fundamental Tool
      3. Practices That Support Change
      4. Test-Driven Development in a Nutshell
      5. The Bigger Picture
      6. Testing End-to-End
      7. Levels of Testing
      8. External and Internal Quality
    2. Chapter 2: Test-Driven Development with Objects
      1. A Web of Objects
      2. Values and Objects
      3. Follow the Messages
      4. Tell, Don’t Ask
      5. But Sometimes Ask
      6. Unit-Testing the Collaborating Objects
      7. Support for TDD with Mock Objects
    3. Chapter 3: An Introduction to the Tools
      1. Stop Me If You’ve Heard This One Before
      2. A Minimal Introduction to JUnit 4
      3. Hamcrest Matchers and assertThat()
      4. jMock2: Mock Objects
  6. Part II: The Process of Test-Driven Development
    1. Chapter 4: Kick-Starting the Test-Driven Cycle
      1. Introduction
      2. First, Test a Walking Skeleton
      3. Deciding the Shape of the Walking Skeleton
      4. Build Sources of Feedback
      5. Expose Uncertainty Early
    2. Chapter 5: Maintaining the Test-Driven Cycle
      1. Introduction
      2. Start Each Feature with an Acceptance Test
      3. Separate Tests That Measure Progress from Those That Catch
      4. Regressions
      5. Start Testing with the Simplest Success Case
      6. Write the Test That You’d Want to Read
      7. Watch the Test Fail
      8. Develop from the Inputs to the Outputs
      9. Unit-Test Behavior, Not Methods
      10. Listen to the Tests
      11. Tuning the Cycle
    3. Chapter 6: Object-Oriented Style
      1. Introduction
      2. Designing for Maintainability
      3. Internals vs Peers
      4. No And’s, Or’s, or But’s
      5. Object Peer Stereotypes
      6. Composite Simpler Than the Sum of Its Parts
      7. Context Independence
      8. Hiding the Right Information
      9. An Opinionated View
    4. Chapter 7: Achieving Object-Oriented Design
      1. How Writing a Test First Helps the Design
      2. Communication over Classification
      3. Value Types
      4. Where Do Objects Come From?
      5. Identify Relationships with Interfaces
      6. Refactor Interfaces Too
      7. Compose Objects to Describe System Behavior
      8. Building Up to Higher-Level Programming
      9. And What about Classes?
    5. Chapter 8: Building on Third-Party Code
      1. Introduction
      2. Only Mock Types That You Own
      3. Mock Application Objects in Integration Tests
  7. Part III: A Worked Example
    1. Chapter 9: Commissioning an Auction Sniper
      1. To Begin at the Beginning
      2. Communicating with an Auction
      3. Getting There Safely
      4. This Isn’t Real
    2. Chapter 10: The Walking Skeleton
      1. Get the Skeleton out of the Closet
      2. Our Very First Test
      3. Some Initial Choices
    3. Chapter 11: Passing the First Test
      1. Building the Test Rig
      2. Failing and Passing the Test
      3. The Necessary Minimum
    4. Chapter 12: Getting Ready to Bid
      1. An Introduction to the Market
      2. A Test for Bidding
      3. The AuctionMessageTranslator
      4. Unpacking a Price Message
      5. Finish the Job
    5. Chapter 13: The Sniper Makes a Bid
      1. Introducing AuctionSniper
      2. Sending a Bid
      3. Tidying Up the Implementation
      4. Contents
      5. Defer Decisions
      6. Emergent Design
    6. Chapter 14: The Sniper Wins the Auction
      1. First, a Failing Test
      2. Who Knows about Bidders?
      3. The Sniper Has More to Say
      4. The Sniper Acquires Some State
      5. The Sniper Wins
      6. Making Steady Progress
    7. Chapter 15: Towards a Real User Interface
      1. A More Realistic Implementation
      2. Displaying Price Details
      3. Simplifying Sniper Events
      4. Follow Through
      5. Final Polish
      6. Observations
    8. Chapter 16: Sniping for Multiple Items
      1. Testing for Multiple Items
      2. Adding Items through the User Interface
      3. Observations
    9. Chapter 17: Teasing Apart Main
      1. Finding a Role
      2. Extracting the Chat
      3. Extracting the Connection
      4. Extracting the SnipersTableModel
      5. Observations
    10. Chapter 18: Filling In the Details
      1. A More Useful Application
      2. Stop When We’ve Had Enough
      3. Observations
    11. Chapter 19: Handling Failure
      1. What If It Doesn’t Work?
      2. Detecting the Failure
      3. Displaying the Failure
      4. Disconnecting the Sniper
      5. Recording the Failure
      6. Observations
  8. Part IV: Sustainable Test-Driven Development
    1. Chapter 20: Listening to the Tests
      1. Introduction
      2. I Need to Mock an Object I Can’t Replace (without Magic)
      3. Logging Is a Feature
      4. Mocking Concrete Classes
      5. Don’t Mock Values
      6. Bloated Constructor
      7. Confused Object
      8. Too Many Dependencies
      9. Too Many Expectations
      10. What the Tests Will Tell Us (If We’re Listening)
    2. Chapter 21: Test Readability
      1. Introduction
      2. Test Names Describe Features
      3. Canonical Test Structure
      4. Streamline the Test Code
      5. Assertions and Expectations
      6. Literals and Variables
    3. Chapter 22: Constructing Complex Test Data
      1. Introduction
      2. Test Data Builders
      3. Creating Similar Objects
      4. Combining Builders
      5. Emphasizing the Domain Model with Factory Methods
      6. Removing Duplication at the Point of Use
      7. Communication First
    4. Chapter 23: Test Diagnostics
      1. Design to Fail
      2. Small, Focused, Well-Named Tests
      3. Explanatory Assertion Messages
      4. Highlight Detail with Matchers
      5. Self-Describing Value
      6. Obviously Canned Value
      7. Tracer Object
      8. Explicitly Assert That Expectations Were Satisfied
      9. Diagnostics Are a First-Class Feature
    5. Chapter 24: Test Flexibility
      1. Introduction
      2. Test for Information, Not Representation
      3. Precise Assertions
      4. Precise Expectations
      5. “Guinea Pig” Objects
  9. Part V: Advanced Topics
    1. Chapter 25: Testing Persistence
      1. Introduction
      2. Isolate Tests That Affect Persistent State
      3. Make Tests Transaction Boundaries Explicit
      4. Testing an Object That Performs Persistence Operations
      5. Testing That Objects Can Be Persisted
      6. But Database Tests Are S-l-o-w!
    2. Chapter 26: Unit Testing and Threads
      1. Introduction
      2. Separating Functionality and Concurrency Policy
      3. Unit-Testing Synchronization
      4. Stress-Testing Passive Objects
      5. Synchronizing the Test Thread with Background Threads
      6. The Limitations of Unit Stress Tests
    3. Chapter 27: Testing Asynchronous Code
      1. Introduction
      2. Sampling or Listening
      3. Two Implementations
      4. Runaway Tests
      5. Lost Updates
      6. Testing That an Action Has No Effect
      7. Distinguish Synchronizations and Assertions
      8. Externalize Event Sources
  10. Afterword: A Brief History of Mock Objects
  11. Appendix A: jMock2 Cheat Sheet
  12. Appendix B: Writing a Hamcrest Matcher
  13. Bibliography