
Unit Testing Principles, Practices, and Patterns
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Radically improve your testing practice and software quality with new testing styles, good patterns, and reliable automation.
Key Features
A practical and results-driven approach to unit testing
Refine your existing unit tests by implementing modern best practices
Learn the four pillars of a good unit test
Safely automate your testing process to save time and money
Spot which tests need refactoring, and which need to be deleted entirely
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About The Book
Great testing practices maximize your project quality and delivery speed by identifying bad code early in the development process. Wrong tests will break your code, multiply bugs, and increase time and costs. You owe it to yourself-and your projects-to learn how to do excellent unit testing.
Unit Testing Principles, Patterns and Practices teaches you to design and write tests that target key areas of your code including the domain model. In this clearly written guide, you learn to develop professional-quality tests and test suites and integrate testing throughout the application life cycle. As you adopt a testing mindset, you'll be amazed at how better tests cause you to write better code.
What You Will Learn
Universal guidelines to assess any unit test
Testing to identify and avoid anti-patterns
Refactoring tests along with the production code
Using integration tests to verify the whole system
This Book Is Written For
For readers who know the basics of unit testing. Examples are written in C# and can easily be applied to any language.
About the Author
Vladimir Khorikov is an author, blogger, and Microsoft MVP. He has mentored numerous teams on the ins and outs of unit testing.
Table of Contents:
PART 1 THE BIGGER PICTURE
1 ¿ The goal of unit testing
2 ¿ What is a unit test?
3 ¿ The anatomy of a unit test
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 toward valuable unit tests
PART 3 INTEGRATION TESTING
8 ¿ Why integration testing?
9 ¿ Mocking best practices
10 ¿ Testing the database
PART 4 UNIT TESTING ANTI-PATTERNS
11 ¿ Unit testing anti-patterns
More details
Other editions
Additional editions

Person
Content
- Intro
- Copyright
- Brief Table of Contents
- Table of Contents
- Preface
- Acknowledgments
- About this book
- About the author
- About the cover illustration
- Part 1. The bigger picture
- Chapter 1. The goal of unit testing
- 1.1. The current state of unit testing
- 1.2. The goal of unit testing
- 1.3. Using coverage metrics to measure test suite quality
- 1.4. What makes a successful test suite?
- 1.5. What you will learn in this book
- Summary
- Chapter 2. What is a unit test?
- 2.1. The definition of "unit test"
- 2.2. The classical and London schools of unit testing
- 2.3. Contrasting the classical and London schools of unit testing
- 2.4. Integration tests in the two schools
- Summary
- Chapter 3. The anatomy of a unit test
- 3.1. How to structure a unit test
- 3.2. Exploring the xUnit testing framework
- 3.3. Reusing test fixtures between tests
- 3.4. Naming a unit test
- 3.5. Refactoring to parameterized tests
- 3.6. Using an assertion library to further improve test readability
- Summary
- Part 2. Making your tests work for you
- Chapter 4. The four pillars of a good unit test
- 4.1. Diving into the four pillars of a good unit test
- 4.2. The intrinsic connection between the first two attributes
- 4.3. The third and fourth pillars: Fast feedback and maintainability
- 4.4. In search of an ideal test
- 4.5. Exploring well-known test automation concepts
- Summary
- Chapter 5. Mocks and test fragility
- 5.1. Differentiating mocks from stubs
- 5.2. Observable behavior vs. implementation details
- 5.3. The relationship between mocks and test fragility
- 5.4. The classical vs. London schools of unit testing, revisited
- Summary
- Chapter 6. Styles of unit testing
- 6.1. The three styles of unit testing
- 6.2. Comparing the three styles of unit testing
- 6.3. Understanding functional architecture
- 6.4. Transitioning to functional architecture and output-based testing
- 6.5. Understanding the drawbacks of functional architecture
- Summary
- Chapter 7. Refactoring toward valuable unit tests
- 7.1. Identifying the code to refactor
- 7.2. Refactoring toward valuable unit tests
- 7.3. Analysis of optimal unit test coverage
- 7.4. Handling conditional logic in controllers
- 7.5. Conclusion
- Summary
- Part 3. Integration testing
- Chapter 8. Why integration testing?
- 8.1. What is an integration test?
- 8.2. Which out-of-process dependencies to test directly
- 8.3. Integration testing: An example
- 8.4. Using interfaces to abstract dependencies
- 8.5. Integration testing best practices
- 8.6. How to test logging functionality
- 8.7. Conclusion
- Summary
- Chapter 9. Mocking best practices
- 9.1. Maximizing mocks' value
- 9.2. Mocking best practices
- Summary
- Chapter 10. Testing the database
- 10.1. Prerequisites for testing the database
- 10.2. Database transaction management
- 10.3. Test data life cycle
- 10.4. Reusing code in test sections
- 10.5. Common database testing questions
- 10.6. Conclusion
- Summary
- Part 4. Unit testing anti-patterns
- Chapter 11. Unit testing anti-patterns
- 11.1. Unit testing private methods
- 11.2. Exposing private state
- 11.3. Leaking domain knowledge to tests
- 11.4. Code pollution
- 11.5. Mocking concrete classes
- 11.6. Working with time
- 11.7. Conclusion
- Summary
- Chapter Map
- Index
- List of Figures
- List of Tables
- List of Listings
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.