Book description
Go beyond basic testing! Great software testing makes the entire development process more efficient. This book reveals a systemic and effective approach that will help you customize your testing coverage and catch bugs in tricky corner cases.In Effective Software Testing you will learn how to:
- Engineer tests with a much higher chance of finding bugs
- Read code coverage metrics and use them to improve your test suite
- Understand when to use unit tests, integration tests, and system tests
- Use mocks and stubs to simplify your unit testing
- Think of pre-conditions, post-conditions, invariants, and contracts
- Implement property-based tests
- Utilize coding practices like dependency injection and hexagonal architecture that make your software easier to test
- Write good and maintainable test code
Effective Software Testing teaches you a systematic approach to software testing that will ensure the quality of your code. It’s full of techniques drawn from proven research in software engineering, and each chapter puts a new technique into practice. Follow the real-world use cases and detailed code samples, and you’ll soon be engineering tests that find bugs in edge cases and parts of code you’d never think of testing! Along the way, you’ll develop an intuition for testing that can save years of learning by trial and error.
About the Technology
Effective testing ensures that you’ll deliver quality software. For software engineers, testing is a key part of the development process. Mastering specification-based testing, boundary testing, structural testing, and other core strategies is essential to writing good tests and catching bugs before they hit production.
About the Book
Effective Software Testing is a hands-on guide to creating bug-free software. Written for developers, it guides you through all the different types of testing, from single units up to entire components. You’ll also learn how to engineer code that facilitates testing and how to write easy-to-maintain test code. Offering a thorough, systematic approach, this book includes annotated source code samples, realistic scenarios, and reasoned explanations.
What's Inside
- Design rigorous test suites that actually find bugs
- When to use unit tests, integration tests, and system tests
- Pre-and post-conditions, invariants, contracts, and property-based tests
- Design systems that are test-friendly
- Test code best practices and test smells
About the Reader
The Java-based examples illustrate concepts you can use for any object-oriented language.
About the Author
Dr. Maurício Aniche is the Tech Academy Lead at Adyen and an Assistant Professor in Software Engineering at the Delft University of Technology.
Quotes
Written for the working developer, it offers state-of-the-art software testing techniques. Perfect for training the next generation of effective software testers.
- From the Foreword by Dr. Arie Van Deursen, Professor in Software Engineering, Delft University
The combination of theory and practice shows the depth of Maurício’s experience as an academic and as a working programmer!
- From the Foreword by Steve Freeman, author of Growing Object-Oriented Software, Guided by Tests
Whether you’re a developer, tester, or student, you’ll find this text an essential part of your work.
- James McKean Wood, Trimble PPM
The first book I’ve read where I finally understood how to write a good unit test, and how to pair it with testable code.
- James Liu, Mediaocean
Publisher resources
Table of contents
- inside front cover
- Effective Software Testing
- Copyright
- brief contents
- contents
- front matter
-
1 Effective and systematic software testing
- 1.1 Developers who test vs. developers who do not
- 1.2 Effective software testing for developers
-
1.3 Principles of software testing (or, why testing is so difficult)
- 1.3.1 Exhaustive testing is impossible
- 1.3.2 Knowing when to stop testing
- 1.3.3 Variability is important (the pesticide paradox)
- 1.3.4 Bugs happen in some places more than others
- 1.3.5 No matter what testing you do, it will never be perfect or enough
- 1.3.6 Context is king
- 1.3.7 Verification is not validation
- 1.4 The testing pyramid, and where we should focus
- Exercises
- Summary
-
2 Specification-based testing
-
2.1 The requirements say it all
- 2.1.1 Step 1: Understanding the requirements, inputs, and outputs
- 2.1.2 Step 2: Explore what the program does for various inputs
- 2.1.3 Step 3: Explore possible inputs and outputs, and identify partitions
- 2.1.4 Step 4: Analyze the boundaries
- 2.1.5 Step 5: Devise test cases
- 2.1.6 Step 6: Automate the test cases
- 2.1.7 Step 7: Augment the test suite with creativity and experience
- 2.2 Specification-based testing in a nutshell
- 2.3 Finding bugs with specification testing
-
2.4 Specification-based testing in the real world
- 2.4.1 The process should be iterative, not sequential
- 2.4.2 How far should specification testing go?
- 2.4.3 Partition or boundary? It does not matter!
- 2.4.4 On and off points are enough, but feel free to add in and out points
- 2.4.5 Use variations of the same input to facilitate understanding
- 2.4.6 When the number of combinations explodes, be pragmatic
- 2.4.7 When in doubt, go for the simplest input
- 2.4.8 Pick reasonable values for inputs you do not care about
- 2.4.9 Test for nulls and exceptional cases, but only when it makes sense
- 2.4.10 Go for parameterized tests when tests have the same skeleton
- 2.4.11 Requirements can be of any granularity
- 2.4.12 How does this work with classes and state?
- 2.4.13 The role of experience and creativity
- Exercises
- Summary
-
2.1 The requirements say it all
-
3 Structural testing and code coverage
- 3.1 Code coverage, the right way
- 3.2 Structural testing in a nutshell
- 3.3 Code coverage criteria
- 3.4 Complex conditions and the MC/DC coverage criterion
- 3.5 Handling loops and similar constructs
- 3.6 Criteria subsumption, and choosing a criterion
- 3.7 Specification-based and structural testing: A running example
- 3.8 Boundary testing and structural testing
- 3.9 Structural testing alone often is not enough
- 3.10 Structural testing in the real world
- 3.11 Mutation testing
- Exercises
- Summary
-
4 Designing contracts
- 4.1 Pre-conditions and post-conditions
- 4.2 Invariants
- 4.3 Changing contracts, and the Liskov substitution principle
- 4.4 How is design-by-contract related to testing?
-
4.5 Design-by-contract in the real world
- 4.5.1 Weak or strong pre-conditions?
- 4.5.2 Input validation, contracts, or both?
- 4.5.3 Asserts and exceptions: When to use one or the other
- 4.5.4 Exception or soft return values?
- 4.5.5 When not to use design-by-contract
- 4.5.6 Should we write tests for pre-conditions, post-conditions, and invariants?
- 4.5.7 Tooling support
- Exercises
- Summary
- 5 Property-based testing
- 6 Test doubles and mocks
-
7 Designing for testability
- 7.1 Separating infrastructure code from domain code
- 7.2 Dependency injection and controllability
- 7.3 Making your classes and methods observable
- 7.4 Dependency via class constructor or value via method parameter?
-
7.5 Designing for testability in the real world
- 7.5.1 The cohesion of the class under test
- 7.5.2 The coupling of the class under test
- 7.5.3 Complex conditions and testability
- 7.5.4 Private methods and testability
- 7.5.5 Static methods, singletons, and testability
- 7.5.6 The Hexagonal Architecture and mocks as a design technique
- 7.5.7 Further reading about designing for testability
- Exercises
- Summary
- 8 Test-driven development
- 9 Writing larger tests
-
10 Test code quality
-
10.1 Principles of maintainable test code
- 10.1.1 Tests should be fast
- 10.1.2 Tests should be cohesive, independent, and isolated
- 10.1.3 Tests should have a reason to exist
- 10.1.4 Tests should be repeatable and not flaky
- 10.1.5 Tests should have strong assertions
- 10.1.6 Tests should break if the behavior changes
- 10.1.7 Tests should have a single and clear reason to fail
- 10.1.8 Tests should be easy to write
- 10.1.9 Tests should be easy to read
- 10.1.10 Tests should be easy to change and evolve
- 10.2 Test smells
- Exercises
- Summary
-
10.1 Principles of maintainable test code
- 11 Wrapping up the book
- Appendix. Answers to exercises
- References
- index
Product information
- Title: Effective Software Testing
- Author(s):
- Release date: April 2022
- Publisher(s): Manning Publications
- ISBN: 9781633439931
You might also like
audiobook
Effective Software Testing
Written for the working developer, it offers state-of-the-art software testing techniques. Perfect for training the next …
book
The Art of Software Testing, 3rd Edition
The classic, landmark work on software testing The hardware and software of computing have changed markedly …
book
Software Testing: Principles and Practices
Software Testing: Principles and Practices is a comprehensive treatise on software testing. It provides a pragmatic …
audiobook
Software Architecture: The Hard Parts
There are no easy decisions in software architecture. Instead, there are many hard parts-difficult problems or …