售价: ¥764.00 待定配送费
前翻 后翻
正在播放... 已暂停   您正在聆听的 Audible 音频版本的样品。
了解更多信息
查看全部 3 张图片

xUnit Test Patterns: Refactoring Test Code (英语) 精装 – 2007年5月31日

| 天天低价·正品质优
|
分享
广告

显示所有 格式和版本 隐藏其他格式和版本
亚马逊价格
全新品最低价 非全新品最低价
精装
"请重试"
¥764.00
¥764.00
促销信息: 优惠 买满 ¥99.00 立减 ¥10.00 共1个促销

 

click to open popover

商品促销和特殊优惠
  • 买满 ¥99.00 立减 ¥10.00: 满足条件自动优惠

看过此商品后顾客买的其它商品?

无需Kindle设备,下载免费Kindle阅读软件,即可在您的手机、电脑及平板电脑上畅享阅读。

  • iPhone/iPad/Mac
  • Android手机或平板电脑

请输入您的手机号码,获取Kindle阅读软件的下载链接。



基本信息

  • 出版社: Addison-Wesley Professional; 1 (2007年5月31日)
  • 丛书名: Addison-Wesley Signature Series (Fowler)
  • 精装: 944页
  • 语种: 英语
  • ISBN: 0131495054
  • 条形码: 0076092037590, 9780131495050
  • 商品尺寸: 17.8 x 5.8 x 23.6 cm
  • 商品重量: 1.7 Kg
  • ASIN: 0131495054
  • 用户评分: 分享我的评价
  • 亚马逊热销商品排名: 图书商品里排第1,359,250名 (查看图书商品销售排行榜)
  • 您想告诉我们您发现了更低的价格?

商品描述

作者简介

Gerard Meszaros is Chief Scientist and Senior Consultant at ClearStream Consulting, a Calgary-based consultancy specializing in agile development. He has more than a decade of experience with automated unit testing frameworks and is a leading expert in test automation patterns, refactoring of software and tests, and design for testability.

目录

Visual Summary of the Pattern Language xvii

Foreword xix

Preface xxi

Acknowledgments xxvi

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

Chapter 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 Verification? 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

Which 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

Defining Tests 76

What's a Fixture? 78

Defining 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

Chapter 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 Verification 107

About This Chapter 107

Making Tests Self-Checking 107

Verify State or Behavior? 108

State Verification 109

Using Built-in Assertions 110

Delta Assertions 111

External Result Verification 111

Verifying Behavior 112

Procedural Behavior Verification 113

Expected Behavior Specification 113

Reducing Test Code Duplication 114

Expected Objects 115

Custom Assertions 116

Outcome-Describing Verification 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 Verification 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

Configuring 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

Right-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 Difficulty 175

Roadmap to Highly Maintainable Automated Tests 176

Exercise the Happy Path Code 177

Verify Direct Outputs of the Happy Path 178

Verify 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

Shared 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 Verification Patterns 461

State Verification 462

Behavior Verification 468

Custom Assertion 474

Delta Assertion 485

Guard Assertion 490

Unfinished Test Assertion 494

Chapter 22 Fixture Teardown Patterns 499

Garbage-Collected Teardown 500

Automated 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

Configurable Test Double 558

Hard-Coded Test Double 568

Test-Specific 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

Derived 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

商品评论

在亚马逊中国上尚未有买家评论。
5 星
4 星
3 星
2 星
1 星

此商品在美国亚马逊上最有用的商品评论 (beta) (可能包括"Early Reviewer Rewards Program"的评论)

美国亚马逊: 平均4.2 星 30 条评论
平均5.0 星 title should be: best test automation book ever 2017年5月2日
评论者 Alex Bernaden III - 已在美国亚马逊上发表
版本: 精装 已确认购买
Every software test engineer should learn this book. Every software developer would rise high above their peers if they understand these concepts. A tour de force of software test automation. As to complaints about length and repetition, read the first half as a story, and use the second half as a reference. An amazingly thorough analysis of how to validate software. A timeless volume because it teaches concepts, and is not tied to any framework. The title is misleading because the book is not primarily about xUnit test patterns or refactoring. If you learn this book, you'll never want for work as a software test engineer.
平均5.0 星 The Reference on xUnit and Automated Testing Patterns 2016年3月11日
评论者 David Moore - 已在美国亚马逊上发表
版本: 精装 已确认购买
The book to read if you want to really understand the xUnit tools, automated testing, and best practices when using them. Even though it was written a number of years ago, it's still very relevant today. Mr. Meszaros obviously has a real depth of experience in testing that he pulls from for this volume. It's a lengthy book, but well worth the read if you want to write better tests, or if you want to develop an xUnit framework. He refers often to Martin Fowler's Refactoring, as well as other books such as the GOF Patterns book, so it might be good to have those handy or read them as well. I will say, it took me quite a while to finally get through this whole book but I was glad I did and read through all of the patterns as well as the "smells". Good stuff, and thanks to Gerard for putting so much time and effort into compiling this volume.
1/1 人认为此评论有用
平均5.0 星 An authoritative work 2013年3月10日
评论者 Puneet S. Lamba - 已在美国亚马逊上发表
版本: 精装 已确认购买
Like the rest of the books in Martin Fowler's signature series, this is an authoritative work on the important subject of unit testing. This is, however, a big book (900 odd pages) and I have no intention of reading it cover to cover. The parts I've gone through are extremely well presented and I have already learned a lot from them. For example, what's the difference between a mock and a stub? The book does have areas of redundancy. For example, there's a fair bit of overlap between chapters 11 (Using Test Doubles) and 23 (Test Double Patterns). I hope I never have to eat these words, but so far I've experienced that investing in a Martin Fowler series book always pays off big time, often in ways you don't imagine. For example, I didn't think that a book on unit test patterns would help to reinforce my concepts on types of inversion of control (IoC) or refactoring, but it did!
3/3 人认为此评论有用
平均4.0 星 More xUnit patterns than you would wish! 2009年6月23日
评论者 Bas Vodde - 已在美国亚马逊上发表
版本: 精装 已确认购买
xUnit Test Patterns by Gerard Meszaros is a huge book. It is almost 900 pages of patterns to be used for test automation and for unit testing. This book contains a huge amount of useful knowledge for developers and is, without a doubt, the most thorough book on writing well-structured unit tests. The largest drawback of the book is its size and the amount of duplication.

The book consists of three parts. The first part is normal prose introducing the patterns and their contexts. The second part is a catalog of test smells and the last part (which is most of the book) describes the test patterns.

The first part of the book is excellent. It contains a couple of chapters related to test automation that are not specific to xUnit test automation. Chapter two introduces test smells, which I found very helpful. Chapter three contains the goals of test automation. This was one of the clearest descriptions I've seen which answer the question "why do we want to do this in the first place." The next chapters are about philosophy (e.g. TDD), principles and strategy. Chapter second introduces xUnit basics and the rest of the chapters of this part are narratives around the pattern sets (chapters) which are introduces further on in the book. The first part is about 180 pages of the book and is definitively worth reading completely. The individual chapters are short and easy to read.

The second part of the book covers test smells. The test smells are grouped intro three categories: code smells, behavior smells and project smells. These smells are also linked to each other, explaining what the "higher level smell" is caused by. I'm afraid I've seen all the smells in real life in the past and thus this part was very recognizable. Nowadays, I often send these smells to people I work with, since Gerard described them perhaps better than I ever could. The test smells are less than a hundred pages

The third part of the book are the test patterns. They are grouped in 'test pattern categories' with each category containing as little as four and as much as ten patterns. The pattern format Gerard uses is clear and easy to read. The largest drawback is that the pattern format causes quite a lot of duplication, especially across patterns. This is because the book is written so that each pattern can be read independently of others. This is good, but for people who read whole books (me) it causes the book to be somewhat boring to read (even though the content is interesting, just felt bored when reading again that there is one exception to object per test-case implementation of most xUnit frameworks).

The first chapter in part three is test strategy patterns, describing different approaches to testing (and this one is not specific to xUnit tests). The next chapter introduces xUnit frameworks written down in pattern form. Fixture setup is next in which the author describes the advantages and disadvantages for fresh vs shared fixtures and how to set them up. Chapter 21 then dives into the assertion parts of an xUnit framework describing the difference between state and behavior verification. Patterns such as custom assertions are frequently used in well-written test code. Next are the teardown patterns in which the authors somewhat promote the automated teardown (something I've not encountered very often in development). Chapter 23 is probably one of the best known chapters where Gerard categorizes test doubles (mocks/stubs/fakes) and describes when to use which term and why? This terminology is far from standardized and his effort to bring clarity in these terms is much appreciated. Next are test organization patterns such as how and where do you split your test case. Chapter 25 covers working with databases. Chapter 26 some general miscellaneous pattern in design which promote low coupling and thus increase testability. The final chapter relates to values within your tests.

The book also (for if this wasn't enough for you) contains over a hundred pages of appendixes. The refactorings, terminology mapping and glossary are useful.

Gerards book is huge. It contains useful insights related to unit testing and writing clean test code. From that perspective, this book is recommended for everyone serious about writing well-factored unit tests. However, the book also contains relative trivial things and, as mentioned, it contains a huge amount of duplication between different parts. This means that perhaps reading the book from cover to cover might not be the best approach :) Part one and two should definitively be read completely, but the patterns in chapter 3 are better browsed and read when needed or e.g. one per week. Another annoying part in the book, for me, was the way Gerard uses comments. Most comments in the code were not useful and made the code obscure and hard to read at times. Wished he had left them out (though, I guess this relates to coding style a lot).

Conclusion. Definitively worth reading or at least browsing for anyone serious about xUnit and test automation. Because of the duplication and the comments, I'd rate it four out of five stars. Personally I'd rather see a small 100 page book containing the summary and conclusions of what Gerard is talking about. It doesn't exist yet, so this book is, at this moment, the best on this particular subject.
平均5.0 星 First, you must snatch the pebble from my hand 2016年4月20日
评论者 paco - 已在美国亚马逊上发表
版本: 精装 已确认购买
The all-time, undisputed heavyweight champeen of unit testing books. An unparalleled exegesis of unit testing. Some might say... "it waaay overanalyzes everything", and "too much needless detail", and I admit for most practical purposes, they'd be right. To do unit testing, you simply don't need all this detail... but... wow... just... whoooooa.... astonishing detail and analysis.