Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Test-Driven Development with C++

You're reading from   Test-Driven Development with C++ A simple guide to writing bug-free Agile code

Arrow left icon
Product type Paperback
Published in Nov 2022
Publisher Packt
ISBN-13 9781803242002
Length 430 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Abdul Wahid Tanner Abdul Wahid Tanner
Author Profile Icon Abdul Wahid Tanner
Abdul Wahid Tanner
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Testing MVP
2. Chapter 1: Desired Test Declaration FREE CHAPTER 3. Chapter 2: Test Results 4. Chapter 3: The TDD Process 5. Chapter 4: Adding Tests to a Project 6. Chapter 5: Adding More Confirm Types 7. Chapter 6: Explore Improvements Early 8. Chapter 7: Test Setup and Teardown 9. Chapter 8: What Makes a Good Test? 10. Part 2: Using TDD to Create a Logging Library
11. Chapter 9: Using Tests 12. Chapter 10: The TDD Process in Depth 13. Chapter 11: Managing Dependencies 14. Part 3: Extending the TDD Library to Support the Growing Needs of the Logging Library
15. Chapter 12: Creating Better Test Confirmations 16. Chapter 13: How to Test Floating-Point and Custom Values 17. Chapter 14: How to Test Services 18. Chapter 15: How to Test With Multiple Threads 19. Index 20. Other Books You May Enjoy

Preface

Many years ago, I started avoiding cookbook-style books when I wanted to learn a new technology or develop a new skill. A book should guide us to understand fundamental ideas so we can adapt our learning to fit our needs. We should not get lost just because a recipe doesn’t match exactly what we want to accomplish.

I also tend to avoid books that are full of theory. You probably know what I mean. Instead of explaining how to use a technology, these books mention ideas with no exploration of putting the ideas into practice. Focusing on either one of these two tangents can leave the learning experience incomplete.

This book is different. Instead of giving you a few simple examples like a cookbook or droning on with rules and definitions, I’ll show you how to use tests to write software that does the following:

  • What users expect and with ease
  • Let’s you add new features without breaking what you’ve already done
  • Clearly communicates what the code does

We’re going to start from the beginning and build multiple projects. You’ll learn what a test is and how it can help by building an easy and natural way to write tests in C++. This is called Test-Driven Development (TDD) and you’ll be using TDD to develop the tools needed for your projects.

In order to get the most benefit from TDD, you’ll need a way to write and run tests. Some programming languages already support TDD while C++ needs extra tools and libraries to support tests. I could have simply explained how to use various TDD tools that already exist. That would be a cookbook approach because each existing solution is slightly different. By starting from the beginning and building what you’ll need, you’ll learn TDD and at the same time you’ll learn how all the other solutions work. The concepts are the same.

For example, most people who learn how to drive a car will be able to drive a pickup truck or a van. Some minor differences are expected but the concepts are the same. Riding a motorcycle is more of a challenge but many of the same concepts are still valid. Driving a bus might need some extra training but is also similar.

If you decide to use other tools or even other languages, you’ll gain a deep understanding of how those other tools work by following the steps in this book. The other tools will be like driving a pickup truck.

This book is divided into three parts. You’ll build a testing library in the first part that will let you write and run tests. You’ll learn how to proceed one step at a time and let the tests guide you.

The second part will use the testing library to start a new project to help you log messages as your software runs. This is a logging library and this project will show you how to build software that meets the needs of your intended customer. You’ll be adding many features to the logging library and you’ll learn how to keep everything working while developing more features.

The intended customer for the logging library is a C++ micro-services developer and this customer focus extends into the third part where you’ll extend the testing library and build a simple service. The service will be used to explain one of the most difficult aspects of software development how to test multiple threads.

All three parts will combine to show you how to use TDD to effectively design and write software that meets the customers needs, gives you the confidence to make changes, and lets other team members understand the design.

lock icon The rest of the chapter is locked
Next Section arrow right
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime