Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

To get the most out of this book

You will need a modern C++ compiler capable of building C++20 or later code. Everything in this book uses standard C++ and will run on any computer. All output is text.

This book lets you build the code with whatever build system you are most comfortable using. The projects all have few files with simple folder structures. You can easily create a project in your code editor and follow along.

This book does not describe finished projects. Each project is a journey. The first chapter starts with an empty project and each subsequent chapter adds to the code already created in previous chapters. You’re encouraged to follow along.

Remember to study the process. This is more important than the actual code that each chapter explains. The TDD process is mentioned many times in this book. The first few chapters introduce you to TDD until there are enough features available in the testing library so that the testing library can be used to build another project. The second logging library project explores the TDD process in more depth and detail. Once the logging library is usable, then both the testing and logging libraries are used to build a simple service project. There is a pattern to the TDD process that repeats. Learning the TDD process through each of the projects will give you the most benefit.

Because the projects are built step by step, you can also benefit from the mistakes explained along the way. Sometimes, the designs will change, and you can benefit from the reasons for the changes as well as learn how to manage the changes.

When I say that you need a C++20 compiler, that’s a simplification. There are many different features of C++ that compiler vendors support in different versions of their compilers. A good rule to follow is to make sure that your compiler supports concepts in C++20. We use concepts in the final chapters of this book and if your compiler supports concepts, then you should have everything you need. A good link to read more is:

https://en.cppreference.com/w/cpp/compiler_support

When you visit the link, scroll down to the C++20 section and look for the row that identifies the concepts feature. At the time of writing, the following compilers should work:

  • GCC version 10
  • Clang version 10
  • MSVC version 19.30
  • Apple Clang version 12 (however, this compiler only has a partial implementation)

You’ll likely be able to use whatever version of the C++ Standard Library that comes with your compiler. However, another good rule that should work is to make sure that your Standard Library also supports concepts. At the time of writing, the following Standard Libraries should work:

  • GCClibstdc++ version 10
  • Clang libc++ version 13
  • MSVC STL version 19.23
  • Apple Clang version 13.1.6

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

lock icon The rest of the chapter is locked
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 $19.99/month. Cancel anytime