The Art of Unit Testing Second Edition WITH EXAMPLES IN C#

JUMU实名认证 发表于 2021-02-17 20:47 | 显示全部楼层 | 复制链接分享      上一主题  翻页  下一主题
To Tal, Itamar, Aviv, and Ido. My family.
One of the biggest failed projects I worked on had unit tests. Or so I thought. I was leading a group of programmers creating a billing application, and we were doing it
in a fully test-driven manner—writing the test, then writing the code, seeing the test fail, making the test pass, refactoring, and starting all over again. The first few months of the project were great. Things were going well, and we had tests that proved that our code worked. But as time went by, requirements changed.
We were forced to change our code to fit those new requirements, and when we did, tests broke and had to be fixed. The code still worked, but the tests we wrote were so
brittle that any little change in our code broke them, even though the code was working fine. It became a daunting task to change code in a class or method because we
also had to fix all the related unit tests.
Worse yet, some tests became unusable because the people who wrote them left the project and no one knew how to maintain the tests or what they were testing. The names we gave our unit testing methods weren’t clear enough, and we had tests relying on other tests. We ended up throwing out most of the tests less than six months into the project.
The project was a miserable failure because we let the tests we wrote do more harm than good. They took more time to maintain and understand than they saved us in
the long run, so we stopped using them. I moved on to other projects, where we did a better job writing our unit tests, and we had some great successes using them, saving huge amounts of debugging and integration time. Since that first failed project, I’ve been compiling best practices for unit tests and using them on subsequent projects. I find a few more best practices with every project I work on.
Understanding how to write unit tests—and how to make them maintainable, readable, and trustworthy—is what this book is about, no matter what language or integrated
development environment (IDE) you work with. This book covers the basics of writing a unit test, moves on to the basics of interaction testing, and introduces best practices for writing, managing, and maintaining unit tests in the real world.

Brief contents
PART 1 GETTING STARTED . .....................................................1
1 ■ The basics of unit testing 3
2 ■ A first unit test 19
PART 2 CORE TECHNIQUES ....................................................47
3 ■ Using stubs to break dependencies 49
4 ■ Interaction testing using mock objects 75
5 ■ Isolation (mocking) frameworks 90
6 ■ Digging deeper into isolation frameworks 109
PART 3 THE TEST CODE .......................................................123
7 ■ Test hierarchies and organization 125
8 ■ The pillars of good unit tests 151
PART 4 DESIGN AND PROCESS ...............................................187
9 ■ Integrating unit testing into the organization 189
10 ■ Working with legacy code 207
11 ■ Design and testability 219

The Art of Unit Testing with examples in C# 9781617290893.pdf

文件大小:13.93 MB

售价: 30 积分 [购买]

  距米网  

找到您想要的设计

工程师、学生在线交流学习平台
关注我们

手机版- 距米网 |苏公网安备32041102000587号

©2017-2025 苏ICP备18040927号-1