Quality Code : Software Testing Principles, Practices, and Patterns
معرفی کتاب «Quality Code : Software Testing Principles, Practices, and Patterns» نوشتهٔ Stephen Vance، منتشرشده توسط نشر Addison-Wesley Professional در سال 2013. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Test-driven, test-first, and test-early development practices are helping thousands of software development organizations improve their software. Now, in **__Quality Code: Software Testing Principles, Practices, and Patterns,__** Stephen Vance builds on all that’s been learned about test-driven development, helping you achieve unprecedented levels of first-time quality. Using real-world code examples, this guide introduces patterns, principles, and more than two dozen detailed techniques for testing any software system more fully, effectively, and painlessly. Vance presents a conceptual framework to help you focus your efforts and design recommendations for improving testability across the software lifecycle, and also provides hands-on guidance to simplify testing of the full spectrum of code constructs. You’ll learn how to choose the best testing techniques for every situation, from the most common scenarios to threading. Two complete case studies put it all together, walking you through testing a brand-new Java application and an untested “legacy” JavaScript jQuery plugin. Whether you’re developing cutting-edge code for a new start-up, or maintaining an unruly old system, this guide will help you deliver exactly what you need: quality code. • Simplify unit testing of all your code—and improve integration and system testing • Delineate intent and implementation to promote more reliable and scalable testing • Overcome confusion and misunderstandings about the mechanics of writing tests • Test “side effects,” behavioral characteristics, and contextual constraints • Understand subtle interactions between design and testability—and make them work for, not against, you • Discover core principles that guide your key testing decisions • Explore testing getters/setters, string handling, encapsulation, override variations, visibility, singleton patterns, error conditions, and more • Reproduce and test complex race conditions deterministically Contents 8 Preface 14 Acknowledgments 18 About the Author 20 Part I: Principles and Practices of Testing 22 Chapter 1: Engineering, Craftsmanship, and First-Time Quality 24 Engineering and Craftsmanship 25 The Role of Craftsmanship in First-Time Quality 25 Practices Supporting Software Craftsmanship 27 Unit Testing under Code Checker Constraints 31 Unit Testing for Coverage 31 Chapter 2: Intent of Code 38 Where Did I Put That Intent? 39 Separating Intent from Implementation 39 A Simple Example That Makes You Think 40 Chapter 3: Where Do I Start? 44 An Approach to Testing 44 The Recipe 49 Chapter 4: Design and Testability 58 A Word on Design Paradigms 58 Encapsulation and Observability 59 Coupling and Testability 63 Chapter 5: Testing Principles 68 Craft Your Tests Well 68 Avoid Test Code in Production 72 Verify Intent over Implementation 73 Minimize Coupling 74 Prefer Minimal, Fresh, Transient Fixtures 75 Use Available Facilities 76 Prefer Complete over Partial Verification 76 Write Small Tests 76 Separate Your Concerns 77 Use Unique Values 78 Keep It Simple: Remove Code 79 Don’t Test the Framework 79 Sometimes Test the Framework 81 Part II: Testing and Testability Patterns 82 Chapter 6: The Basics 84 Bootstrapping Constructors 84 Testing Simple Getters and Setters 87 Share Constants 88 Locally Redefine 91 Temporarily Replace 92 Encapsulate and Override 93 Adjust Visibility 96 Verification by Injection 98 Chapter 7: String Handling 102 Verification by Containment 102 Verification by Pattern 104 Exact Verification by Value 106 Exact Verification with Formatted Results 109 Chapter 8: Encapsulation and Override Variations 112 Data Injection 112 Encapsulate Loop Conditions 115 Error Injection 117 Replace Collaborators 119 Use Existing No-Op Classes 122 Chapter 9: Adjusting Visibility 126 Packaging Tests with Code 126 Break It Down 129 Changing Access Levels 130 Test-Only Interfaces 132 Naming the Unnamed 133 Becoming friend-ly 134 Coerced Access via Reflection 135 Declarative Scope Changing 137 Chapter 10: Interlude: Revisiting Intent 140 Testing the Singleton Pattern 141 Singleton Intent 142 The Testing Strategy 142 Discerning Intent 148 Chapter 11: Error Condition Verification 150 Check the Return Value 150 Verify the Exception Type 151 Verify the Exception Message 153 Verify the Exception Payload 155 Verify the Exception Instance 158 Thoughts on Exception Design 161 Chapter 12: Use Existing Seams 166 Direct Calls 167 Dependency Injection 168 Callbacks, Observers, Listeners, and Notifiers 171 Registries 175 Factories 177 Logging and Other Facilities of Last Resort 180 Chapter 13: Parallelism 186 A Brief Introduction to Threads and Race Conditions 187 A Strategy for Race Condition Reproduction 191 Test the Thread Task Directly 194 Synchronize through Common Lock 197 Synchronize through Injection 202 Use Supervisory Control 205 Statistical Verification 208 Debugger APIs 210 Part III: Worked Examples 214 Chapter 14: Test-Driven Java 216 Bootstrapping 217 First Functionality 218 Cutting the Cord 219 Moving to Multiples 220 Ghost Protocol 221 Exercising Options 224 Moving Downstream 225 Retrospective 228 Chapter 15: Legacy JavaScript 230 Getting Started 231 DOMination 232 On Toothpaste and Testing 234 Scaling Up 236 Software Archeology 238 Retrospective 239 Bibliography 240 Index 242 A 242 B 242 C 243 D 244 E 245 F 245 G 246 H 246 I 246 J 246 L 247 M 247 N 248 O 248 P 248 R 249 S 249 T 250 U 251 V 251 W 252 X 252 Y 252 Test-driven, test-first, and test-early development practices are helping thousands of software development organizations improve their software. Now, in Quality Code: Software Testing Principles, Practices, and Patterns, Stephen Vance builds on all that's been learned about test-driven development, helping you achieve unprecedented levels of first-time quality. Using real-world code examples, this guide introduces patterns, principles, and more than two dozen detailed techniques for testing any software system more fully, effectively, and painlessly. Vance presents a conceptual framework to help you focus your efforts and design recommendations for improving testability across the software lifecycle, and also provides hands-on guidance to simplify testing of the full spectrum of code constructs. You'll learn how to choose the best testing techniques for every situation, from the most common scenarios to threading. Two complete case studies put it all together, walking you through testing a brand-new Java application and an untested 'legacy' JavaScript jQuery plugin. Whether you're developing cutting-edge code for a new start-up, or maintaining an unruly old system, this guide will help you deliver exactly what you need: quality code. Simplify unit testing of all your code - and improve integration and system testing; Delineate intent and implementation to promote more reliable and scalable testing; Overcome confusion and misunderstandings about the mechanics of writing tests; Test 'side effects,' behavioral characteristics, and contextual constraints; Understand subtle interactions between design and testability - and make them work for, not against, you; Discover core principles that guide your key testing decisions; Explore testing getters/setters, string handling, encapsulation, override variations, visibility, singleton patterns, error conditions, and more; Reproduce and test complex race conditions deterministically
دانلود کتاب Quality Code : Software Testing Principles, Practices, and Patterns