The NIST estimates that poor testing costs the US economy $60 billion annually. This book gives teams straightforward and proven ways to introduce unit testing into their process, resulting in higher quality and fewer bugs.All over the world, software teams are using unit testing both to verify thei
Pragmatic Unit Testing in C# with NUnit (Pragmatic Programmers)
โ Scribed by Andy Hunt, Dave Thomas
- Publisher
- The Pragmatic Programmers
- Year
- 2004
- Tongue
- English
- Leaves
- 163
- Series
- Pragmatic Programmers
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
This book is a slim one, just over 200 pages, and provides an easy introduction to writing unit tests. It explains the concept of unit testing, why they are beneficial, and carries on with how to write and manage tests.
The reader is gently introduced to the code, and shown how a unit test can be written without a test framework. NUnit is then introduced and is used to automate most of the gritty details. There is a basic overview of mock objects, and a mention of the NMock tool. The book briefly mentions test-driven development, code coverage, UI tests, and refactoring, but does not go into them in any depth. Which is fine, since this is intended as a focused introduction to unit testing.
For anyone new to unit testing in .NET, this book is worth a read. It does not go into much depth, but does the job as introductory material. If you are already comfortable with unit testing and NUnit, I can recommend The Art of Unit Testing: With Examples in .Net as a more advanced book.
โฆ Table of Contents
About the Starter Kit......Page 8
Preface......Page 10
Introduction......Page 13
Coding With Confidence......Page 14
What is Unit Testing?......Page 15
What Do I Want to Accomplish?......Page 16
Excuses For Not Testing......Page 19
Roadmap......Page 24
Your First Unit Tests......Page 25
Planning Tests......Page 26
Testing a Simple Method......Page 27
Running Tests with NUnit......Page 28
Running the Example......Page 34
More Tests......Page 38
Structuring Unit Tests......Page 39
NUnit Asserts......Page 40
NUnit Framework......Page 43
NUnit Test Selection......Page 45
NUnit Custom Asserts......Page 51
NUnit and Exceptions......Page 53
Temporarily Ignoring Tests......Page 54
Are the Results Right?......Page 56
Boundary Conditions......Page 60
Cross-check Using Other Means......Page 61
Force Error Conditions......Page 62
Performance Characteristics......Page 63
CORRECT Boundary Conditions......Page 65
Conformance......Page 66
Ordering......Page 67
Range......Page 69
Reference......Page 72
Existence......Page 73
Cardinality......Page 74
Time......Page 76
Try It Yourself......Page 78
Using Mock Objects......Page 82
Simple Stubs......Page 83
Mock Objects......Page 84
Formalizing Mock Objects......Page 88
When Not To Mock......Page 102
Properties of Good Tests......Page 104
Automatic......Page 105
Thorough......Page 106
Independent......Page 108
Professional......Page 109
Testing the Tests......Page 111
Where to Put Test Code......Page 114
Test Courtesy......Page 117
Test Frequency......Page 118
Tests and Legacy Code......Page 119
Tests and Reviews......Page 122
Designing for Testability......Page 125
Refactoring for Testing......Page 127
Testing the Class Invariant......Page 138
Test-Driven Design......Page 140
Testing Invalid Parameters......Page 142
``Smoke'' Tests......Page 144
Floating-Point Problems......Page 145
Tests Keep Breaking......Page 146
Tests Fail on Some Machines......Page 147
On The Web......Page 148
Bibliography......Page 150
Summary: Pragmatic Unit Testing......Page 151
Answers to Exercises......Page 152
๐ SIMILAR VOLUMES
Even if you are familiar with Unit Testing, JUnit, and Test Driven Development your skills will be sharpened by the content in this book. The book jumps right into general principles of unit testing such as what to test, how much test code to write, and when to test. A concept named Right-BICEP is i
Even if you are familiar with Unit Testing, JUnit, and Test Driven Development your skills will be sharpened by the content in this book. The book jumps right into general principles of unit testing such as what to test, how much test code to write, and when to test. A concept named Right-BICEP is i
In the second volume of the sequence, Hunt and Thomas (software developers) offer guidance on writing better code, detecting and fixing potential problems, testing pieces of code, and testing with a whole team. They describe the process of unit testing with the freely-available JUnit library in Java