𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Modern C++ programming with test-driven development code better, sleep better

✍ Scribed by Langr, Jeff


Publisher
Pragmatic Bookshelf; Pragmatic Programmers
Year
2013;2014
Tongue
English
Leaves
360
Series
The pragmatic programmers
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


If you program in C++ you've been neglected. Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to change your software to meet changing needs. But C++ programmers have been ignored by those promoting TDD--until now. In this book, Jeff Langr gives you hands-on lessons in the challenges and rewards of doing TDD in C++.

Modern C++ Programming With Test-Driven Development, the only comprehensive treatment on TDD in C++ provides you with everything you need to know about TDD, and the challenges and benefits of implementing it in your C++ systems. Its many detailed code examples take you step-by-step from TDD basics to advanced concepts. As a veteran C++ programmer, you're already writing high-quality code, and you work hard to maintain code quality. It doesn't have to be that hard.

In this book, you'll learn:

how to use TDD to improve legacy C++ systems

how to identify and deal with troublesome system dependencies

how to do dependency injection, which is particularly tricky in C++

how to use testing tools for C++ that aid TDD

new C++11 features that facilitate TDD

As you grow in TDD mastery, you'll discover how to keep a massive C++ system from becoming a design mess over time, as well as particular C++ trouble spots to avoid. You'll find out how to prevent your tests from being a maintenance burden and how to think in TDD without giving up your hard-won C++ skills. Finally, you'll see how to grow and sustain TDD in your team.

Whether you're a complete unit-testing novice or an experienced tester, this book will lead you to mastery of test-driven development in C++.

What You Need

A C++ compiler running under Windows or Linux, preferably one that supports C++11. Examples presented in the book were built under gcc 4.7.2.

Google Mock 1.6 (downloadable for free; it contains Google Test as well) or an alternate C++ unit testing tool. Most examples in the book are written for Google Mock, but it isn't difficult to translate them to your tool of choice.

A good programmer's editor or IDE.

cmake, preferably. Of course, you can use your own preferred make too. CMakeLists.txt files are provided for each project. Examples provided were built using cmake version 2.8.9.

Various freely-available third-party libraries are used as the basis for examples in the book. These include: - cURL - JsonCpp - Boost (filesystem, date_time/gregorian, algorithm, assign) Several examples use the boost headers/libraries. Only one example uses cURL and JsonCpp.

✦ Table of Contents


Cover......Page 1
Title......Page 4
Copyright......Page 5
Contents......Page 6
Foreword......Page 11
Introduction......Page 13
But Can It Work for Me on My System?......Page 15
What You’ll Need......Page 16
How to Use This Book......Page 17
About Me......Page 20
About the C++ Style in This Book......Page 21
Dedication......Page 22
1.2 The Examples......Page 23
1.3 C++ Compiler......Page 25
1.5 Google Mock......Page 28
1.6 CppUTest......Page 30
1.7 libcurl......Page 31
1.9 rlog......Page 32
1.11 Building Examples and Running Tests......Page 34
1.12 Teardown......Page 35
2.2 The Soundex Class......Page 36
2.3 Getting Started......Page 37
2.4 Fixing Unclean Code......Page 44
2.5 Incrementalism......Page 46
2.6 Fixtures and Setup......Page 49
2.7 Thinking and TDD......Page 51
2.8 Test-Driving vs. Testing......Page 54
2.9 What If?......Page 57
2.10 One Thing at a Time......Page 58
2.11 Limiting Length......Page 60
2.12 Dropping Vowels......Page 61
2.13 Doing What It Takes to Clarify Tests......Page 62
2.14 Testing Outside the Box......Page 64
2.15 Back on Track......Page 66
2.16 Refactoring to Single-Responsibility Functions......Page 67
2.18 What Tests Are We Missing?......Page 69
2.19 Our Solution......Page 70
2.20 The Soundex Class......Page 71
2.21 Teardown......Page 75
3.2 Unit Test and TDD Fundamentals......Page 76
3.3 The TDD Cycle: Red-Green-Refactor......Page 78
3.4 The Three Rules of TDD......Page 80
3.5 Getting Green on Red......Page 81
3.6 Mind-Sets for Successful Adoption of TDD......Page 90
3.7 Mechanics for Success......Page 94
3.8 Teardown......Page 98
4.2 Organization......Page 99
4.3 Fast Tests, Slow Tests, Filters, and Suites......Page 106
4.4 Assertions......Page 109
4.5 Inspecting Privates......Page 116
4.6 Testing vs. Test-Driving: Parameterized Tests and Other Toys......Page 120
4.7 Teardown......Page 123
5.2 Dependency Challenges......Page 124
5.3 Test Doubles......Page 125
5.4 A Hand-Crafted Test Double......Page 126
5.5 Improving Test Abstraction When Using Test Doubles......Page 131
5.6 Using Mock Tools......Page 133
5.7 Getting Test Doubles in Place......Page 142
5.8 Design Will Change......Page 149
5.9 Strategies for Using Test Doubles......Page 151
5.10 Miscellaneous Test Double Topics......Page 155
5.11 Teardown......Page 157
6.2 Simple Design......Page 159
6.3 Where Is the Up-Front Design?......Page 184
6.4 Refactoring Inhibitors......Page 187
6.5 Teardown......Page 189
7.2 Tests Come FIRST......Page 191
7.3 One Assert per Test......Page 196
7.4 Test Abstraction......Page 199
7.5 Teardown......Page 212
8.2 Legacy Code......Page 213
8.3 Themes......Page 214
8.4 The Legacy Application......Page 216
8.5 A Test-Driven Mentality......Page 219
8.6 Safe Refactoring to Support Testing......Page 220
8.7 Adding Tests to Characterize Existing Behavior......Page 223
8.8 Sidetracked by the Reality of Legacy Code......Page 224
8.9 Creating a Test Double for rlog......Page 225
8.10 Test-Driving Changes......Page 229
8.11 A New Story......Page 231
8.12 A Brief Exploration in Seeking Faster Tests......Page 232
8.13 Mondo Extracto......Page 233
8.14 Spying to Sense Using a Member Variable......Page 236
8.15 Spying to Sense Using a Mock......Page 237
8.17 Large-Scale Change with the Mikado Method......Page 242
8.18 An Overview of the Mikado Method......Page 243
8.19 Moving a Method via Mikado......Page 244
8.20 More Thoughts on the Mikado Method......Page 254
8.21 Is It Worth It?......Page 255
8.22 Teardown......Page 256
9.2 Core Concepts for Test-Driving Threads......Page 257
9.3 The GeoServer......Page 258
9.4 Performance Requirements......Page 264
9.5 Designing an Asynchronous Solution......Page 267
9.6 Still Simply Test-Driving......Page 270
9.7 Ready for a Thready!......Page 272
9.8 Exposing Concurrency Issues......Page 274
9.9 Creating Client Threads in the Test......Page 277
9.10 Creating Multiple Threads in the ThreadPool......Page 279
9.11 Back to the GeoServer......Page 281
9.12 Teardown......Page 285
10.2 TDD and Performance......Page 286
10.3 Unit Tests, Integration Tests, and Acceptance Tests......Page 295
10.4 The Transformation Priority Premise......Page 298
10.5 Writing Assertions First......Page 311
10.6 Teardown......Page 315
11.1 Setup......Page 316
11.2 Explaining TDD to Nontechies......Page 317
11.3 The Bad Test Death Spiral, aka the SCUMmy Cycle......Page 321
11.4 Pair Programming......Page 323
11.5 Katas and Dojos......Page 327
11.6 Using the Code Coverage Metric Effectively......Page 330
11.7 Continuous Integration......Page 331
11.8 Deriving Team Standards for TDD......Page 332
11.9 Keeping Up with the Community......Page 333
11.10 Teardown......Page 334
A1.2 TDD Unit Testing Tool Features......Page 336
A1.5 Other Unit Testing Frameworks......Page 338
A1.6 Teardown......Page 339
A2.2 Let’s Go!......Page 340
A2.4 Teardown......Page 348
A3. Bibliography......Page 349
C......Page 351
G......Page 352
L......Page 353
R......Page 354
T......Page 355
W......Page 356
Z......Page 357

✦ Subjects


Computer Science;Programming;Science;Software;Engineering;Computers;Technology


πŸ“œ SIMILAR VOLUMES


Modern C++ programming with test-driven
✍ Jeff Langr πŸ“‚ Library πŸ“… 2013 πŸ› Pragmatic Bookshelf 🌐 English

If you program in C++ youve been neglected. Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to change your software to meet changing needs. But C++ progr

Modern C++ programming with test-driven
✍ Jeff Langr πŸ“‚ Library πŸ“… 2013 πŸ› Pragmatic Bookshelf 🌐 English

If you program in C++ you've been neglected. Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to change your software to meet changing needs. But C++ prog

Modern C++ Programming with Test-Driven
✍ Jeff Langr πŸ“‚ Library πŸ“… 2013 πŸ› The Pragmatic Programmers 🌐 English

If you program in C++ you've been neglected. Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to change your software to meet changing needs. But C++ prog

Modern C++ Programming with Test-Driven
✍ Jeff Langr πŸ“‚ Library πŸ“… 2013 πŸ› Pragmatic Bookshelf 🌐 English

If you program in C++ youve been neglected. Test-driven development (TDD) is a modern software development practice that can dramatically reduce the number of defects in systems, produce more maintainable code, and give you the confidence to change your software to meet changing needs. But C++ progr

Test-Driven Development in Swift: Compil
✍ Gio Lodi πŸ“‚ Library πŸ“… 2021 πŸ› Apress 🌐 English

<p>Leverage Swift to practice effective and efficient test-driven development (TDD) methodology. Software testing and TDD are evergreen programming concepts―yet Swift developers haven't widely adopted them. What's needed is a clear roadmap to learn and adopt TDD in the Swift world. Over the past yea