自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Magicpang

Tracking the Road

  • 博客(2)
  • 资源 (16)
  • 收藏
  • 关注

原创 记录所有接收过的vCard

Nokia6300发出的vCard,注意在quoted-printed中使用的折行=/x0D/x0A同quoted-printable是一样的,但是同RFC822中所说的是不一样的。BEGIN:VCARDVERSION:2.1N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=E8=BD=A6=E6=9D=A5=E6=8E=A5=E7=94==B5;=E9=9

2008-11-11 13:14:00 4582

原创 Linker和loader的一些网站

Sunhttp://blogs.sun.com/rie/http://blogs.sun.com/msw/http://blogs.sun.com/ali/可以从google搜索site:www.airs.com/blog/archives "linkers part"http://airs.com/blog/wiki上面的http://en.wikipedia.org/wiki/Linkerli

2008-11-10 13:54:00 621

cjson so linux

cjson so linux all by hand 3

2015-06-09

lua模块cjsondll

找了好久没有找到cjson在windows下的dll,所以自己编了一个,算是一个备份吧。

2015-06-09

C.Plus.Plus.Template.Metaprogramming.

Copyright The C++ In-Depth Series Titles in the Series Preface Acknowledgments Dave's Acknowledgments Aleksey's Acknowledgments Making the Most of This Book Supplementary Material Trying It Out Chapter 1. Introduction Section 1.1. Getting Started Section 1.2. So What's a Metaprogram? Section 1.3. Metaprogramming in the Host Language Section 1.4. Metaprogramming in C++ Section 1.5. Why Metaprogramming? Section 1.6. When Metaprogramming? Section 1.7. Why a Metaprogramming Library? Chapter 2. Traits and Type Manipulation Section 2.1. Type Associations Section 2.2. Metafunctions Section 2.3. Numerical Metafunctions Section 2.4. Making Choices at Compile Time Section 2.5. A Brief Tour of the Boost Type Traits Library Section 2.6. Nullary Metafunctions Section 2.7. Metafunction Definition Section 2.8. History Section 2.9. Details Section 2.10. Exercises Chapter 3. A Deeper Look at Metafunctions Section 3.1. Dimensional Analysis Section 3.2. Higher-Order Metafunctions Section 3.3. Handling Placeholders Section 3.4. More Lambda Capabilities Section 3.5. Lambda Details Section 3.6. Details Section 3.7. Exercises Chapter 4. Integral Type Wrappers and Operations Section 4.1. Boolean Wrappers and Operations Section 4.2. Integer Wrappers and Operations Section 4.3. Exercises Chapter 5. Sequences and Iterators Section 5.1. Concepts Section 5.2. Sequences and Algorithms Section 5.3. Iterators Section 5.4. Iterator Concepts Section 5.5. Sequence Concepts Section 5.6. Sequence Equality Section 5.7. Intrinsic Sequence Operations Section 5.8. Sequence Classes Section 5.9. Integral Sequence Wrappers Section 5.10. Sequence Derivation Section 5.11. Writing Your Own Sequence Section 5.12. Details Section 5.13. Exercises Chapter 6. Algorithms Section 6.1. Algorithms, Idioms, Reuse, and Abstraction Section 6.2. Algorithms in the MPL Section 6.3. Inserters Section 6.4. Fundamental Sequence Algorithms Section 6.5. Querying Algorithms Section 6.6. Sequence Building Algorithms Section 6.7. Writing Your Own Algorithms Section 6.8. Details Section 6.9. Exercises Chapter 7. Views and Iterator Adaptors Section 7.1. A Few Examples Section 7.2. View Concept Section 7.3. Iterator Adaptors Section 7.4. Writing Your Own View Section 7.5. History Section 7.6. Exercises Chapter 8. Diagnostics Section 8.1. Debugging the Error Novel Section 8.2. Using Tools for Diagnostic Analysis Section 8.3. Intentional Diagnostic Generation Section 8.4. History Section 8.5. Details Section 8.6. Exercises Chapter 9. Crossing the Compile-Time/Runtime Boundary Section 9.1. for_each Section 9.2. Implementation Selection Section 9.3. Object Generators Section 9.4. Structure Selection Section 9.5. Class Composition Section 9.6. (Member) Function Pointers as Template Arguments Section 9.7. Type Erasure Section 9.8. The Curiously Recurring Template Pattern Section 9.9. Explicitly Managing the Overload Set Section 9.10. The "sizeof Trick" Section 9.11. Summary Section 9.12. Exercises Chapter 10. Domain-Specific Embedded Languages Section 10.1. A Little Language ... Section 10.2. ... Goes a Long Way Section 10.3. DSLs, Inside Out Section 10.4. C++ as the Host Language Section 10.5. Blitz++ and Expression Templates Section 10.6. General-Purpose DSELs Section 10.7. The Boost Spirit Library Section 10.8. Summary Section 10.9. Exercises Chapter 11. A DSEL Design Walkthrough Section 11.1. Finite State Machines Section 11.2. Framework Design Goals Section 11.3. Framework Interface Basics Section 11.4. Choosing a DSL Section 11.5. Implementation Section 11.6. Analysis Section 11.7. Language Directions Section 11.8. Exercises Appendix A. An Introduction to Preprocessor Metaprogramming Section A.1. Motivation Section A.2. Fundamental Abstractions of the Preprocessor Section A.3. Preprocessor Library Structure Section A.4. Preprocessor Library Abstractions Section A.5. Exercise Appendix B. The typename and template Keywords Section B.1. The Issue Section B.2. The Rules Appendix C. Compile-Time Performance Section C.1. The Computational Model Section C.2. Managing Compilation Time Section C.3. The Tests Appendix D. MPL Portability Summary CD-ROM Warranty Bibliography

2012-06-18

advanced programming in unix env中文版

advanced programming in unix env 中文

2009-11-03

o'reilly - perl testing - a developer's notebook (2006).chm

< Day Day Up > Perl Testing: A Developer's Notebook By chromatic , Ian Langworth ............................................... Publisher: O'Reilly Pub Date: July 2005 ISBN: 0-596-10092-2 Pages: 208 Table of Contents | Index | Errata -------------------------------------------------------------------------------- Copyright The Developer's Notebook Series Notebooks Are... Notebooks Aren't... Organization Preface What This Book Covers Conventions Used in This Book Using Code Examples Safari Enabled Comments and Questions Acknowledgments Chapter 1. Beginning Testing Installing Test Modules Running Tests Interpreting Test Results Writing Your First Test Loading Modules Improving Test Comparisons Chapter 2. Writing Tests Skipping Tests Skipping All Tests Marking Tests as TODO Simple Data Structure Equality Data Composition Testing Warnings Testing Exceptions Chapter 3. Managing Tests Organizing Tests Checking Your Coverage Writing a Testing Library Testing a Testing Library Writing a Testing Harness Testing Across the Network Automating Test Runs Chapter 4. Distributing Your Tests (and Code) Testing POD Files Testing Documentation Coverage Distribution Signatures Testing Entire Distributions Letting the User Decide Letting the User Decide (Continued) Bundling Tests with Modules Collecting Test Results Validating Kwalitee Chapter 5. Testing Untestable Code Overriding Built-ins Mocking Modules Mocking Objects Partially Mocking Objects Overriding Live Code Overriding Operators Everywhere Chapter 6. Testing Databases Shipping Test Databases Testing Database Data Using Temporary Databases Mocking Databases Chapter 7. Testing Web Sites Testing Your Backend Testing Your Frontend Record and Play Back Browsing Sessions Testing the Validity of HTML Running Your Own Apache Server Testing with Apache-Test Distributing Modules with Apache-Test Chapter 8. Unit Testing with Test::Class Writing Test Cases Creating Test Fixtures Inheriting Tests Skipping Tests with Test::Class Marking Tests as TODO with Test::Class Chapter 9. Testing Everything Else Writing Testable Programs Testing Programs Testing Interactive Programs Testing Shared Libraries Colophon About the Authors Colophon Index < Day Day Up >

2009-04-14

Addison.Wesley.xUnit.Test.Patterns.Refactoring.Test.Code.May.2007.pdf

Contents Visual Summary of the Pattern Language . . . . . . . . . . . . . . . . . . . xvii Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix Refactoring a Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xlv PART I. The Narratives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 1. A Brief Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 The Simplest Test Automation Strategy That Could Possibly Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Development Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Customer Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Unit Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Design for Testability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Test Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Chapter 2. Test Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 An Introduction to Test Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 What’s a Test Smell? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Kinds of Test Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 What to Do about Smells? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 A Catalog of Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 The Project Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 The Behavior Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 The Code Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 viiChapter 3. Goals of Test Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Why Test? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Economics of Test Automation . . . . . . . . . . . . . . . . . . . . . . . . . 20 Goals of Test Automation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Tests Should Help Us Improve Quality . . . . . . . . . . . . . . . . . . . 22 Tests Should Help Us Understand the SUT . . . . . . . . . . . . . . . . . 23 Tests Should Reduce (and Not Introduce) Risk . . . . . . . . . . . . . 23 Tests Should Be Easy to Run . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Tests Should Be Easy to Write and Maintain . . . . . . . . . . . . . . . 27 Tests Should Require Minimal Maintenance as the System Evolves Around Them . . . . . . . . . . . . . . . . . . . . . . . 29 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Chapter 4. Philosophy of Test Automation . . . . . . . . . . . . . . . . . . . . . . . . . 31 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Why Is Philosophy Important? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Some Philosophical Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Test First or Last? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Tests or Examples? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Test-by-Test or Test All-at-Once? . . . . . . . . . . . . . . . . . . . . . . . . 33 Outside-In or Inside-Out? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 State or Behavior Verifi cation? . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Fixture Design Upfront or Test-by-Test? . . . . . . . . . . . . . . . . . . 36 When Philosophies Differ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 My Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Chapter 5. Principles of Test Automation . . . . . . . . . . . . . . . . . . . . . . . . . . 39 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 The Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Chapter 6. Test Automation Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 What’s Strategic? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Which Kinds of Tests Should We Automate? . . . . . . . . . . . . . . . . . 50 Per-Functionality Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Cross-Functional Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Contents viiiWhich Tools Do We Use to Automate Which Tests? . . . . . . . . . . . . 53 Test Automation Ways and Means . . . . . . . . . . . . . . . . . . . . . . . 54 Introducing xUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 The xUnit Sweet Spot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Which Test Fixture Strategy Do We Use? . . . . . . . . . . . . . . . . . . . . 58 What Is a Fixture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Major Fixture Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Transient Fresh Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Persistent Fresh Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Shared Fixture Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 How Do We Ensure Testability? . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Test Last—at Your Peril . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Design for Testability—Upfront . . . . . . . . . . . . . . . . . . . . . . . . . 65 Test-Driven Testability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Control Points and Observation Points . . . . . . . . . . . . . . . . . . . 66 Interaction Styles and Testability Patterns . . . . . . . . . . . . . . . . . 67 Divide and Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Chapter 7. xUnit Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 An Introduction to xUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Common Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 The Bare Minimum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Defi ning Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 What’s a Fixture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Defi ning Suites of Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Running Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Test Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Under the xUnit Covers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Test Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Test Suite Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 xUnit in the Procedural World . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Contents ixChapter 8. Transient Fixture Management . . . . . . . . . . . . . . . . . . . . . . . . . 85 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Test Fixture Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 What Is a Fixture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 What Is a Fresh Fixture? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 What Is a Transient Fresh Fixture? . . . . . . . . . . . . . . . . . . . . . . . 87 Building Fresh Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 In-line Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Delegated Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Implicit Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Hybrid Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Tearing Down Transient Fresh Fixtures . . . . . . . . . . . . . . . . . . . . . 93 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Chapter 9. Persistent Fixture Management . . . . . . . . . . . . . . . . . . . . . . . . . .95 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Managing Persistent Fresh Fixtures . . . . . . . . . . . . . . . . . . . . . . . . 95 What Makes Fixtures Persistent? . . . . . . . . . . . . . . . . . . . . . . . . 95 Issues Caused by Persistent Fresh Fixtures . . . . . . . . . . . . . . . . . 96 Tearing Down Persistent Fresh Fixtures . . . . . . . . . . . . . . . . . . . 97 Avoiding the Need for Teardown . . . . . . . . . . . . . . . . . . . . . . . 100 Dealing with Slow Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Managing Shared Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Accessing Shared Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Triggering Shared Fixture Construction . . . . . . . . . . . . . . . . . . 104 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Chapter 10. Result Verifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Making Tests Self-Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Verify State or Behavior? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 State Verifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Using Built-in Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Delta Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 External Result Verifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Verifying Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Procedural Behavior Verifi cation . . . . . . . . . . . . . . . . . . . . . . . 113 Expected Behavior Specifi cation . . . . . . . . . . . . . . . . . . . . . . . . 113 Contents xReducing Test Code Duplication . . . . . . . . . . . . . . . . . . . . . . . . . 114 Expected Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Custom Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Outcome-Describing Verifi cation Method . . . . . . . . . . . . . . . . 117 Parameterized and Data-Driven Tests . . . . . . . . . . . . . . . . . . . 118 Avoiding Conditional Test Logic . . . . . . . . . . . . . . . . . . . . . . . . . 119 Eliminating “if” Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Eliminating Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Other Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Working Backward, Outside-In . . . . . . . . . . . . . . . . . . . . . . . . 121 Using Test-Driven Development to Write Test Utility Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Where to Put Reusable Verifi cation Logic? . . . . . . . . . . . . . . . . . . 122 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Chapter 11. Using Test Doubles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 What Are Indirect Inputs and Outputs? . . . . . . . . . . . . . . . . . . . . 125 Why Do We Care about Indirect Inputs? . . . . . . . . . . . . . . . . . 126 Why Do We Care about Indirect Outputs? . . . . . . . . . . . . . . . 126 How Do We Control Indirect Inputs? . . . . . . . . . . . . . . . . . . . 128 How Do We Verify Indirect Outputs? . . . . . . . . . . . . . . . . . . . 130 Testing with Doubles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Types of Test Doubles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Providing the Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Confi guring the Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Installing the Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Other Uses of Test Doubles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Endoscopic Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Need-Driven Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Speeding Up Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Speeding Up Test Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Other Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Chapter 12. Organizing Our Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Basic xUnit Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Contents xiRight-Sizing Test Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Test Methods and Testcase Classes . . . . . . . . . . . . . . . . . . . . . . . . 155 Testcase Class per Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Testcase Class per Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Testcase Class per Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Choosing a Test Method Organization Strategy . . . . . . . . . . . . 158 Test Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Organizing Test Suites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Running Groups of Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Running a Single Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Test Code Reuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Test Utility Method Locations . . . . . . . . . . . . . . . . . . . . . . . . . 163 TestCase Inheritance and Reuse . . . . . . . . . . . . . . . . . . . . . . . . 163 Test File Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Built-in Self-Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Test Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Test Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Chapter 13. Testing with Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Testing with Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Why Test with Databases? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Issues with Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Testing without Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Testing the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Testing Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Testing the Data Access Layer . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Ensuring Developer Independence. . . . . . . . . . . . . . . . . . . . . . . 173 Testing with Databases (Again!) . . . . . . . . . . . . . . . . . . . . . . . . . . 173 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Chapter 14. A Roadmap to Effective Test Automation . . . . . . . . . . . . . . . 175 About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Test Automation Diffi culty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Roadmap to Highly Maintainable Automated Tests . . . . . . . . . . . 176 Exercise the Happy Path Code . . . . . . . . . . . . . . . . . . . . . . . . . 177 Verify Direct Outputs of the Happy Path . . . . . . . . . . . . . . . . . 178 Contents xiiVerify Alternative Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Verify Indirect Output Behavior . . . . . . . . . . . . . . . . . . . . . . . . 179 Optimize Test Execution and Maintenance . . . . . . . . . . . . . . . 180 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 PART II. The Test Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Chapter 15. Code Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Obscure Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Conditional Test Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Hard-to-Test Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Test Code Duplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Test Logic in Production . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Chapter 16. Behavior Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Assertion Roulette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Erratic Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Fragile Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Frequent Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Manual Intervention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Slow Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Chapter 17. Project Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Buggy Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 Developers Not Writing Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 High Test Maintenance Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Production Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 PART III. The Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Chapter 18. Test Strategy Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Recorded Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Scripted Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Data-Driven Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Test Automation Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Minimal Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 Standard Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Fresh Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 Contents xiiiShared Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 Back Door Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Layer Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Chapter 19. xUnit Basics Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 Test Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 Four-Phase Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 Assertion Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 Assertion Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 Testcase Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 Test Runner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 Testcase Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 Test Suite Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 Test Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 Test Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 Test Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 Chapter 20. Fixture Setup Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 In-line Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 Delegated Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 Creation Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 Implicit Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 Prebuilt Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 Lazy Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 Suite Fixture Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 Setup Decorator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 Chained Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 Chapter 21. Result Verifi cation Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 461 State Verifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 Behavior Verifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468 Custom Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 Delta Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 Guard Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490 Unfi nished Test Assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 Chapter 22. Fixture Teardown Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 499 Garbage-Collected Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 Contents xivAutomated Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503 In-line Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 Implicit Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516 Chapter 23. Test Double Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 Test Stub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 Test Spy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 Mock Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544 Fake Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 Confi gurable Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558 Hard-Coded Test Double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568 Test-Specifi c Subclass. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579 Chapter 24. Test Organization Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 591 Named Test Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 Test Utility Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599 Parameterized Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607 Testcase Class per Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 Testcase Class per Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 Testcase Class per Fixture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631 Testcase Superclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638 Test Helper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643 Chapter 25. Database Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649 Database Sandbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650 Stored Procedure Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 Table Truncation Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 Transaction Rollback Teardown . . . . . . . . . . . . . . . . . . . . . . . . . . 668 Chapter 26. Design-for-Testability Patterns . . . . . . . . . . . . . . . . . . . . . . . . 677 Dependency Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678 Dependency Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686 Humble Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 Test Hook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709 Chapter 27. Value Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713 Literal Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 Contents xvDerived Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 Generated Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 Dummy Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728 PART IV. Appendixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733 Appendix A. Test Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 Appendix B. xUnit Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741 Appendix C. xUnit Family Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 Appendix D. Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753 Appendix E. Goals and Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757 Appendix F. Smells, Aliases, and Causes . . . . . . . . . . . . . . . . . . . . . . . . . . 761 Appendix G. Patterns, Aliases, and Variations . . . . . . . . . . . . . . . . . . . . . . 767 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835 Visual Summary of the Pattern Language xvi

2009-04-04

计算机程序艺术 英文版 第三卷 part5

计算机程序艺术 英文版 第三卷 part5

2009-03-14

计算机程序艺术 英文版 第三卷 part4

计算机程序艺术 英文版 第三卷 part4

2009-03-14

计算机程序艺术 英文版 第三卷 part3

计算机程序艺术 英文版 第三卷 共五个压缩包, 这个是第三个

2009-03-08

计算机程序艺术 英文版 第三卷 part2

计算机程序艺术 英文版 第三卷 共五个压缩包, 这个是第二个

2009-03-02

计算机程序艺术第三卷

计算机程序艺术 英文版,第三卷,共5个压缩包,这是第一个

2009-02-27

Understanding and Writing Compilers

A do-it-yourself guide 自己写一个编译器

2009-02-24

Compilers:Principles, Techniques, and Tools

Compilers:Principles, Techniques, and Tools第二版,总共两个分包,这是第一个

2008-10-05

Compilers:Principles, Techniques, and Tools

Compilers:Principles, Techniques, and Tools 第二版,总共两个分包,这是第二部分

2008-10-05

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除