FREEYou can see any available part of this book for free.
Click the table of contents to start reading.
Unit Testing: Principles, Patterns and Practices shows you how to refine your existing unit tests by implementing modern best practices. You’ll learn to spot which tests are performing, which need refactoring, and which need to be deleted entirely! Upgrade your testing suite with new testing styles, good patterns, and reliable automated testing.
This is the kind of book on unit testing I have been waiting on for a long time.
Table of Contents takes you straight to the bookdetailed table of contents
Part 1: The bigger picture
1 The goal of unit testing
1.1 The current state of unit testing
1.2 The goal of unit testing
1.2.1 What makes a good or bad test?
1.3 Using coverage metrics to measure test suite quality
1.3.1 Understanding the code coverage metric
1.3.2 Understanding the branch coverage metric
1.3.3 Problems with coverage metrics
1.3.4 Aiming at a particular coverage number
1.4 What makes a successful test suite?
1.4.1 It’s integrated into the development cycle
1.4.2 It only targets the most important parts of your code base
1.4.3 It provides maximum value with minimum maintenance costs
1.5 What you will learn in this book
2 What is a unit test?
2.1 The definition of "unit test"
2.1.1 The isolation issue: the London take
2.1.2 The isolation issue: the classical take
2.2 The classical and London schools of unit testing
2.2.1 How the classical and London schools handle dependencies
2.3 Contrasting the classical and London schools of unit testing
2.3.1 Unit testing one class at a time
2.3.2 Unit testing a large graph of interconnected classes
2.3.3 Revealing the precise bug location
2.3.4 Other differences between the classical and London schools
2.4 Integration tests
2.4.1 End-to-end tests are a subset of integration tests
3 The anatomy of a unit test
3.1 How to structure a unit test
3.1.1 Using the Arrange-Act-Assert pattern
3.1.2 Avoid multiple arrange, act, assert sections
3.1.3 Avoid if statements in tests
3.1.4 How large should each section be?
3.1.5 Differentiating the system under test
3.1.6 Dropping the arrange, act, assert comments from tests
3.2 Exploring the xUnit testing framework
3.3 Reusing test fixtures between tests
3.3.1 High coupling between tests is an anti-pattern
3.3.2 The use of constructors in tests diminishes test readability
3.3.3 A better way to reuse test fixtures
3.4 Naming a unit test
3.4.1 Unit test naming guidelines
3.4.2 Example: renaming a test towards the guidelines
3.5 Refactoring to parameterized tests
3.5.1 Generating data for parameterized tests
3.6 Using an assertion library to further improve test readability
Part 2: Making your tests work for you
4 The four pillars of a good unit test
5 Mocks and test fragility
6 Styles of unit testing
7 Refactoring towards valuable unit tests
Part 3: Integration testing
8 Why integration testing?
9 Working with the database
Part 4: Unit testing best practices
10 Test-first vs code-first approaches to unit testing
11 Sharing code between tests
Part 5: Unit testing anti-patterns
12 Non-determinism in tests
13 Common anti-patterns
About the TechnologyTest automation has turned unit testing into a standard practice in software development. Too often, unit testing doesn’t deliver the project quality and feedback speed developers expect. The right unit test suite gives great outcomes and is vital to delivering quality software; the wrong tests can break your code, drag on with bugs and upkeep costs, and take more time to fix than they save. Ensuring your testing suite maximizes its potential isn’t about writing more tests—it’s about implementing the best practices that give real value and minimise upkeep costs.
About the bookUnit Testing: Principles, Practices and Patterns is a practical guide to modern unit testing best practices. Microsoft MVP Vladimir Khorikov takes you hands-on with examples of the ideal unit test and unit testing practices, building your skills step by step on a solid foundation. You’ll explore how to design and write tests that check the right aspects of your applications, develop effective and maintainable test suites, and automate your testing process safely. When you are done, you will have a best practice testing suite that ensures your projects are easier to maintain, easier to scale, and easier to adapt to changing needs.
- A universal frame of reference by which to assess any unit test
- Common anti-patterns to identify and avoid
- Guidelines on how to refactor a test suite along with the production code it covers
- Using integration tests to verify the behavior of the system as a whole
About the readerFor readers who know the basics of unit testing and want to improve their techniques to get the best return on their efforts. Examples are in C# but apply in any language
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
placing your order...Don't refresh or navigate away from the page.
customers also bought