Contents


preface
acknowledgments
about this book
about the cover illustration

Part 1 Foundations

Chapter 1 The promise of good tests
State of the union: writing better tests
The value of having tests
Tests as a design tool
Summary
Chapter 2 In search of good
Readable code is maintainable code
Structure helps make sense of things
It’s not good if it’s testing the wrong things
Independent tests run easily in solitude
Reliable tests are reliable
Every trade has its tools and tests are no exception
Summary
Chapter 3 Test doubles
The power of a test double
Types of test doubles
Guidelines for using test doubles
Summary

Part 2 Catalog

Chapter 4 Readability
Primitive assertions
Hyperassertions
Bitwise assertions
Incidental details
Split personality
Split logic
Magic numbers
Setup sermon
Overprotective tests
Summary
Chapter 5 Maintainability
Duplication
Conditional logic
Flaky test
Crippling file path
Persistent temp files
Sleeping snail
Pixel perfection
Parameterized mess
Lack of cohesion in methods
Summary 113
Chapter 6 Trustworthiness
Commented-out tests
Misleading comments
Never-failing tests
Shallow promises
Lowered expectations
Platform prejudice
Conditional tests
Summary

Part 3 Diversions

Chapter 7 Testable design
What’s testable design?
Testability issues
Guidelines for testable design
Summary
Chapter 8 Writing tests in other JVM languages
The premise of mixing JVM languages
Writing unit tests with Groovy
Expressive power with BDD tools
Summary
Chapter 9 Speeding up test execution
Looking for a speed-up
Speeding up test code
Speeding up the build
Summary

 
appendix A JUnit primer
appendix B Extending JUnit
index