{{sellerTotalView > 1 ? __("sellers", {number: sellerTotalView}) : __("seller", {number: sellerTotalView}) }}, {{numTotalView > 1 ? __("items", {number: numTotalView}) : __("item", {number: numTotalView}) }}
free FREE

Change Your Zip Code

Inventory information and delivery speeds may vary for different locations.

Location History

{{email ? __('Got it!') : __('Restock Alert')}}

We will notify you by email when the item back in stock.

Cancel
Yami

Jingdong book

单元测试的艺术(第2版)

{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}

单元测试的艺术(第2版)

{{__(":people-members", {'people': item.limit_people_count})}} {{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ item.invalid_price }} {{ itemDiscount }}
Ends in
{{ itemCurrency }}{{ item.valid_price }}
{{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }}
{{ itemDiscount }}
{{ itemCurrency }}{{ item.valid_price }} {{ itemCurrency }}{{ priceFormat(item.valid_price / item.bundle_specification) }}/{{ item.unit }} {{ itemCurrency }}{{ item.invalid_price }} {{itemDiscount}}
{{ itemCurrency }}{{ item.valid_price }}
Sale ends in
Sale will starts after Sale ends in
{{ getSeckillDesc(item.seckill_data) }}
{{ __( "Pay with Gift Card to get sale price: :itemCurrency:price", { 'itemCurrency' : itemCurrency, 'price' : (item.giftcard_price ? priceFormat(item.giftcard_price) : '0.00') } ) }} ({{ itemCurrency }}{{ priceFormat(item.giftcard_price / item.bundle_specification) }}/{{ item.unit }}) Details
Best before

Currently unavailable.

We don't know when or if this item will be back in stock.

Unavailable in your area.
Sold Out

Details

Full product details
Editer Recommend

基础概念+代码+具体分析,手把手教你学测试
解密神秘魔法:隔离框架
测试“不可测试”的代码

Content Description

《单元测试的艺术(第2版)》是经典的单元测试学习指南,分四部分全面介绍了单元测试技术。第1部分阐述单元测试基本概念,包括如何使用测试框架。第二部分讨论破除依赖的高级技术:模拟对象、存根和隔离框架,包括重构代码以使用这些技术的模式。第三部分介绍测试代码的组织方式、运行测试和重构测试结构的模式,以及编写测试的实践。第四部分介绍如何在组织内实施变革和修改现有代码。
《单元测试的艺术(第2版)》适合所有语言的测试和开发人员,特别是测试主管和项目经理。
Author Description

Roy Osherove,世界单元测试专家,常年为世界各地的开发团队提供咨询和培训服务,并在各种大会上发表演讲,内容包括单元测试及测试驱动开发的艺术、团队领导力和敏捷开发实践。其个人技术博客osherove.com平均月独立访问量约50 000,提供了各种技术视频及其他培训信息,另著有Notes to a Software Team Leader: Growing Self Organizing Teams。
Comments

“不管你是单元测试和测试驱动开发的新手,还是已经有了丰富经验的人,都能在这本书里找到适合自己的内容。请准备好欣赏Roy给你演唱的‘单元测试的艺术’。”
——Robert C. Martin,软件开发大师,设计模式和敏捷开发先驱,敏捷联盟首任主席,被后辈程序员尊称为“Bob大叔”

“它是这一领域的经典之作,是学习单元测试的必读之书!”
——Raphael Faria,LG公司

“本书集思想性与实用性于一体。”
——Pradeep Chellappan,微软公司

“每当团队成员问我如何正确编写单元测试,我都会这样回答:看这本书!”
——Alessandro Campeis,Vimar SpA

“学习单元测试图书,没有之一!”
——Kaleb Pederson,Next IT
Catalogue

第一部分入门
第1章单元测试基础2
1.1逐步定义单元测试2
1.1.1编写优秀单元测试的重要性4
1.1.2我们都写过(某种)单元测试4
1.2优秀单元测试的特性5
1.3集成测试5
1.4什么是优秀的单元测试9
1.5一个简单的单元测试范例9
1.6测试驱动开发12
1.7成功进行TDD的三种核心技能15
1.8小结15

第2章第一个单元测试17
2.1单元测试框架18
2.1.1单元测试框架提供什么18
2.1.2xUnit框架20
2.2LogAn项目介绍20
2.3NUnit初步20
2.3.1安装NUnit21
2.3.2加载解决方案22
2.3.3在代码中使用NUnit属性24
2.4编写第一个测试25
2.4.1Assert类25
2.4.2用NUnit运行第一个测试26
2.4.3添加正检验27
2.4.4从红到绿:测试成功28
2.4.5测试代码格式28
2.5使用参数重构测试28
2.6更多NUnit属性30
2.6.1setup和teardown30
2.6.2检验预期的异常33
2.6.3忽略测试35
2.6.4NUnit的方法语法36
2.6.5设置测试类别37
2.7测试系统状态的改变而非返回值37
2.8小结41

第二部分核心技术
第3章使用存根破除依赖44
3.1存根简介44
3.2发现LogAn中对文件系统的依赖45
3.3如何使测试LogAnalyzer变得容易46
3.4重构代码设计以提高可测试性48
3.4.1抽取接口使底层实现可替换49
3.4.2依赖注入:在被测试单元中注入一个伪实现51
3.4.3在构造函数层注入一个伪对象(构造函数注入)51
3.4.4用伪对象模拟异常55
3.4.5用属性get或set注入伪对象56
3.4.6在方法调用前注入伪对象57
3.5重构技术变种63
3.6克服封装问题65
3.6.1使用internal和[InternalsVisibleTo]65
3.6.2使用[Conditional]属性66
3.6.3使用#if和#endif进行条件编译66
3.7小结67

第4章使用模拟对象进行交互测试68
4.1基于值的测试、基于状态的测试和交互测试68
4.2模拟对象和存根的区别70
4.3手工模拟对象的简单示例71
4.4同时使用模拟对象和存根73
4.5每个测试一个模拟对象78
4.6伪对象链:用存根生成模拟对象或其他存根78
4.7手工模拟对象和存根的问题79
4.8小结80

第5章隔离(模拟)框架81
5.1为什么要使用隔离框架81
5.2动态生成伪对象83
5.2.1在测试中使用NSubstitute83
5.2.2用动态伪对象替换手工伪对象84
5.3模拟值86
5.4测试事件相关的活动92
5.4.1测试事件监听者92
5.4.2测试事件是否触发93
5.5现有的.NET隔离框架94
5.6隔离框架的优缺点95
5.6.1使用隔离框架时应避开的陷阱96
5.6.2测试代码不可读96
5.6.3验证错误的事情96
5.6.4一个测试多个模拟对象96
5.6.5过度指定测试97
5.7小结97

第6章深入了解隔离框架99
6.1受限框架及不受限框架99
6.1.1受限框架99
6.1.2不受限框架100
6.1.3基于探查器的不受限框架如何工作101
6.2优秀隔离框架的价值103
6.3支持适应未来和可用性的功能103
6.3.1递归伪对象104
6.3.2默认忽略参数104
6.3.3泛伪造105
6.3.4伪对象的非严格行为105
6.3.5非严格模拟对象106
6.4隔离框架设计反模式106
6.4.1概念混淆106
6.4.2录制和重放107
6.4.3粘性行为109
6.4.4复杂语法109
6.5小结109

第三部分测试代码
第7章测试层次和组织112
7.1运行自动化测试的自动化构建112
7.1.1构建脚本结构113
7.1.2触发构建和集成115
7.2基于速度和类型布局测试116
7.2.1分离集成测试和单元测试的人为因素117
7.2.2绿色安全区117
7.3确保测试是源代码管理的一部分118
7.4将测试类映射到被测试代码118
7.4.1将测试映射到项目118
7.4.2将测试映射到类118
7.4.3将测试映射到具体的工作单元入口119
7.5注入横切关注点120
7.6为应用程序构建测试API122
7.6.1使用测试类继承模式122
7.6.2创建测试工具类和方法133
7.6.3把你的API介绍给开发人员134
7.7小结134

第8章优秀单元测试的支柱136
8.1编写可靠的测试136
8.1.1决定何时删除或修改测试137
8.1.2避免测试中的逻辑140
8.1.3只测试一个关注点142
8.1.4把单元测试和集成测试分开143
8.1.5用代码审查确保代码覆盖率143
8.2编写可维护的测试144
8.2.1测试私有或受保护的方法145
8.2.2去除重复代码146
8.2.3以可维护的方式使用setup方法149
8.2.4实施测试隔离151
8.2.5避免对不同关注点多次断言156
8.2.6对象比较158
8.2.7避免过度指定160
8.3编写可读的测试162
8.3.1单元测试命名162
8.3.2变量命名163
8.3.3有意义的断言164
8.3.4断言和操作分离165
8.3.5setup和teardown165
8.4小结166

第四部分设计和流程
第9章在组织中引入单元测试168
9.1逐步成为变革的倡导者168
9.1.1准备好面对质疑169
9.1.2说服组织内成员:支持者和反对者169
9.1.3找到可能的切入点169
9.2成功之道171
9.2.1游击式实现(自下而上)171
9.2.2说服高层(自上而下)171
9.2.3引入外援172
9.2.4使进度可见172
9.2.5设定具体目标173
9.2.6应对障碍175
9.3失败原因175
9.3.1缺少驱动力175
9.3.2缺乏政策支持175
9.3.3不好的实现和第一印象176
9.3.4缺少团队支持176
9.4影响因素176
9.5质疑和回答177
9.5.1单元测试会给现有流程增加多少时间178
9.5.2单元测试是否会抢了QA饭碗179
9.5.3证明单元测试确实有效的方法179
9.5.4单元测试有用的证据180
9.5.5QA部门还是能找到缺陷的原因180
9.5.6我们有大量没有测试的代码:应该从哪里开始181
9.5.7我们使用多种编程语言:单元测试是否可行181
9.5.8软硬件结合的开发181
9.5.9确保测试中没有缺陷的方法181
9.5.10我的代码已经调试通过了,但还需要测试的原因182
9.5.11驱动开发测试的必要性182
9.6小结182

第10章遗留代码183
10.1从哪里开始增加测试183
10.2决定选择策略185
10.2.1先易后难策略的优缺点185
10.2.2先难后易策略的优缺点186
10.3在重构前编写集成测试186
10.4遗留代码单元测试的重要工具187
10.4.1使用不受限的隔离框架轻松隔离依赖项187
10.4.2使用JMockit测试Java遗留代码189
10.4.3重构Java代码时使用Vise190
10.4.4重构前使用验收测试191
10.4.5阅读Michael Feathers关于遗留代码的书192
10.4.6使用NDepend调查产品代码192
10.4.7使用ReSharper浏览和重构产品代码192
10.4.8使用Simian和TeamCity发现重复代码(和缺陷)193
10.5小结193

第11章设计与可测试性194
11.1为什么在设计时要关心可测试性194
11.2可测试性的设计目标195
11.2.1默认情况下将方法设置为虚拟方法195
11.2.2使用基于接口的设计196
11.2.3默认情况下将类设置为非密封的196
11.2.4避免在包含逻辑的方法内初始化具体类197
11.2.5避免直接调用静态方法197
11.2.6避免在构造函数和静态构造函数中包含逻辑代码197
11.2.7把单例逻辑和单例持有者分开198
11.3可测试性设计的利弊199
11.3.1工作量199
11.3.2复杂度200
11.3.3泄露敏感知识产权200
11.3.4有时无法实现200
11.4可测试性设计的替代方法200
11.5难以测试的设计示例202
11.6小结205
11.7更多资源206

附录A工具和框架208

Introduction

我工作过的最失败的一个项目就使用了单元测试。或者说,我是这么认为的。那时我带领着一队程序员开发一个记账应用,采取的是彻底的测试驱动开发方式:编写测试,然后编写代码;看到测试失败,使测试通过,重构代码;然后再开始新一轮过程。
项目前期的几个月非常好,所有的事情都很顺利,我们有测试可以证明代码工作正常。但是随着时间的推移,需求发生了变化。我们被迫修改代码以适应新的需求,但是这样一来,测试失败了,需要修复。产品代码还是可以正常工作的,但是我们编写的测试过于脆弱,代码中任何微小的改变都会导致测试失败,哪怕代码工作正常。修改类或方法中的代码成了一项令人生畏的任务,因为同时还需要修复所有相关的单元测试。
更糟糕的是,因为有些人离开了这个项目,没有人知道他们测试的是什么,也不知道如何维护他们的测试,这些测试就无法使用了。我们给单元测试方法起的名字不够清楚,还有的测试互相依赖。最后的结果是,项目才开始不到6个月,我们就扔掉了大部分的测试。
这个项目是个悲剧,我们让自己编写的测试造成的损失比带来的收益多。从长远来看,维护和理解这些测试花费的时间,超过了它们能为我们节省的时间,因此我们停止使用它们了。我此后又参加过别的项目,这些项目中的单元测试做得好一些,我们使用这些测试获得了很大的成功,节省了大量的调试和集成时间。从那第一个失败的项目之后,我一直在整理单元测试的最佳实践,并在之后的项目中应用。在每个工作过的项目中,我总能找到更多的最佳实践。
理解如何编写单元测试,以及如何使它们可维护、可读和可靠,是这本书的内容,不管你使用的是何种语言或集成开发环境(IDE)。这本书涵盖了编写单元测试的基本知识,然后讲解交互测试基础,介绍了在真实世界中编写、管理和维护单元测试的最佳实践。

Specifications

Brand Jingdong book
Brand Origin China

Disclaimer

Product packaging, specifications and price are subject to change without notice. All information about the products on our website is provided for information purposes only. Please always read labels, warnings and directions provided with the product before use.

View Full Terms of Use
Add to favorites
{{ $isZh ? coupon.coupon_name_sub : coupon.coupon_ename_sub | formatCurrency }}
{{__("Buy Directly")}} {{ itemCurrency }}{{ item.directly_price }}
Quantity
{{ quantity }}
{{ instockMsg }}
{{ limitText }}
{{buttonTypePin == 3 ? __("Scan to view more PinGo") : __("Scan to start")}}
Sold by JD@CHINA
Ship to
{{ __("Ship to United States only") }}
Free shipping over 69
Genuine guarantee

Added to Cart

Keep Shopping

More to Consider

{{ item.brand_name }}

{{ item.item_name }}

{{ item.currency }}{{ item.market_price }}

{{ item.currency }}{{ item.unit_price }}

{{ item.currency }}{{ item.unit_price }}

Coupons

{{ coupon.coupon_name_new | formatCurrency }}
Clip Clipped Over
{{ getCouponDescStr(coupon) }}
{{ coupon.use_time_desc }}
Expires soon {{ formatTime(coupon.use_end_time) }}

Share this item with friends

Cancel

Yami Gift Card

Get this exclusive deal when paying with gift card

Terms and Conditions

Gift card deals are special offers for selected products;

The gift card deals will automatically be activated if a customer uses gift card balance at check out and the balance is sufficient to pay for the total price of the shopping cart products with gift card deals;

You will not be able to activate the gift card deals if you choose other payment methods besides gift card. The products will be purchased at their normal prices;

If your account balance is not enough to pay for the products with gift card deals, you can choose to reload your gift card balance by clicking on the Reload button at either shopping cart page or check out page;

Products that have gift card deals can be recognized by a special symbol showing 'GC Deal';

For any additional questions or concerns, please contact our customer service;

Yamibuy reserves the right of final interpretation.

Sold by Yami

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

Yami is committed to provide our customers with a peace of mind when purchasing from us. Most items shipped from Yamibuy.com can be returned within 30 days of receipt of shipment (For Food, Beverages, Snacks, Dry Goods, Health supplements, Fresh Grocery and Perishables Goods, within 7 days of receipt of shipment due to damages or quality issues; To ensure that every customer receives safe and high-quality products, we do not provide refunds or returns for beauty products once they have been opened or used, except in the case of quality issues; Some products may have different policies or requirements associated with them, please see below for products under special categories, or contact Yami Customer Service for further assistance).
Thank you for your understanding and support.

Learn More

Sold by Yami

Terms and Conditions of Yami E-Gift Card

If you choose “Redeem automatically” as your delivery method, your gift card balance will be reload automatically after your order has been processed successfully;

If you choose “Send to Email”as your delivery method, the card number and CVV will be sent to the email address automatically;

Any user can use the card number and CVV to redeem the gift card, please keep your gift card information safely. If you have any trouble receiving email, please contact Yami customer service;

Yami gift card can be used to purchase both Yami owned or Marketplace products;

Yami gift card will never expire;

Yami gift card balance does not have to be used up at once;

All rights reserved by Yami.

Return Policy

Gift card that has already been consumed is non-refundable.

Sold by JD@CHINA

Service Guarantee

Yami Free Shipping over $49
Yami Easy Returns
Yami Ships from United States

Shipping

  • United States

    Standard Shipping is $5.99 (Excluding Alaska & Hawaii). Free on orders of $49 or more.

    Local Express is $5.99 (Available in Parts of CA, NJ, MA & PA). Free on orders of $49 or more.

    2-Day Express (Includes Alaska & Hawaii) starts at $19.99.

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Sold by JD@CHINA

Service Guarantee

Yami Cross-store Free Shipping over $69
Yami 30-days Return

Yami-China FC

Yami has a consolidation warehouse in China which collects multiple sellers’ packages and combines to one order. Our Yami consolidation warehouse will directly ship the packages to your door. Cross-store free shipping over $69.

Return Policy

You may return products within 30 days upon receiving the products. Sellers take responsibilities for any wrong shipment or missing items. Packing needs to be unopened for any other than quality issues return. We promise to pack carefully, but because goods are taking long journey to destinations, simple damages to packaging may occur. Any damages not causing internal goods quality problems are not allowed to return. If you open the package and any quality problem is found, please contact customer service within three days after receipt of goods.

Shipping Information

Yami Consolidation Service Shipping Fee $9.99(Free shipping over $69)

Sellers in China will ship their orders within 1-2 business days once the order is placed. Packages are sent to our consolidation warehouse in China and combined there. Our Yami consolidation warehouse will directly ship the packages to you via UPS. The average time for UPS to ship from China to the United States is about 10 working days and it can be traced using the tracking number. Due to the pandemic, the delivery time may be delayed by about 5 days. The package needs to be signed by the guest. If the receipt is not signed, the customer shall bear the risk of loss of the package.

Sold by JD@CHINA

Service Guarantee

Free shipping over 69
Genuine guarantee

Shipping

Yami Consolidated Shipping $9.99(Free shipping over $69)


Seller will ship the orders within 1-2 business days. The logistics time limit is expected to be 7-15 working days. In case of customs clearance, the delivery time will be extended by 3-7 days. The final receipt date is subject to the information of the postal company.

Yami Points information

All items are excluding from any promotion or points events on Yamibuy.com

Return Policy

You may return product within 30 days upon receiving the product. Items returned must be new in it's original packing, including the original invoice for the purchase. Customer return product at their own expense.

Yami

Download the Yami App

Back Top

Recommended for You

About the brand

Jingdong book

为您推荐

Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折
Yami
欣葉
2种选择
欣叶 御大福 芋头麻薯 180g

周销量 600+

$1.66 $1.99 83折

Reviews{{'('+ commentList.posts_count + ')'}}

Have your say. Be the first to help other guests.

Write a review
{{ totalRating }} Write a review
  • {{i}} star

    {{i}} stars

    {{ parseInt(commentRatingList[i]) }}%

Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}
Yami Yami
{{ comment.user_name }}

{{ showTranslate(comment) }}Show Less

{{ strLimit(comment,800) }}Show more

Show Original

{{ comment.content }}

Yami
Show All

{{ formatTime(comment.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ comment.likes_count }} {{ comment.likes_count }} {{ comment.reply_count }} {{comment.in_user==uid ? __('Delete') : __('Report')}}

No related comment~

Review

Yami Yami

{{ showTranslate(commentDetails) }}Show Less

{{ strLimit(commentDetails,800) }}Show more

Show Original

{{ commentDetails.content }}

Yami
Show All

{{ formatTime(commentDetails.in_dtm) }} VERIFIED PURCHASE {{groupData}}

{{ commentDetails.likes_count }} {{ commentDetails.likes_count }} {{ commentDetails.reply_count }} {{commentDetails.in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Comments{{'(' + replyList.length + ')'}}

Yami Yami

{{ showTranslate(reply) }}Show Less

{{ strLimit(reply,800) }}Show more

Show Original

{{ reply.reply_content }}

{{ formatTime(reply.reply_in_dtm) }}

{{ reply.reply_likes_count }} {{ reply.reply_likes_count }} {{ reply.reply_reply_count }} {{reply.reply_in_user==uid ? __('Delete') : __('Report')}}

Please write at least one word

Cancel

That’s all the comments so far!

Write a review
How would you rate this item?

Please add your comment.

  • A nice nickname will make your comments more popular!
  • The nickname in your account will be changed to the same as here.
Thanks for your review
Our community rely on great reviews like yours to find the best of Asia.

Report

If you find this content inappropriate and think it should be removed from the Yami.com site, let us know please.

Cancel

Are you sure to delete your review?

Cancel

You’ve Recently Viewed

About the brand

Jingdong book