Test-Driven Development with C++: A simple guide to writing bug-free Agile code
Book information
Description
Learn how to write a simple testing framework and extend it to drive the design of your logging library Key FeaturesLearn how to solve various challenges when testing in C++ with the help of effective solutionsDevelop a logging library with enhancementsDrive better code designs with effective testsBook Description Modern, standard C++ is all that is needed to create a small and practical testing framework that will improve the design of any project. This allows you to think about how the code will be used, which is the first step in designing intuitive interfaces. TDD is a modern balanced software development approach that helps to create maintainable applications, provide modularity in design, and write minimal code that drastically reduces defects. With the help of this book, you'll be able to continue adding value when designs need to change by ensuring that the changes don't break existing tests. In this book, developers working with test-driven development (TDD) will be able to put their knowledge to work by writing a simple testing framework and then using it to drive the design of a logging library. The book will help you enhance your software development skills with test cases. You'll understand how to design and implement test cases. The chapters will also show you how to utilize the TDD approach to be more productive in software development than attempting to code in large unstructured steps. By the end of this book, you'll have gained knowledge of TDD and testing and also built a working logging library. What you will learnUnderstand how to develop software using TDDKeep the code for the system as error-free as possibleRefactor and redesign code confidentlyCommunicate the requirements and behaviors of the code with your teamUnderstand the differences between unit tests and integration testsUse TDD to create a minimal viable testing frameworkWho this book is for This book is for C++ developers already familiar with and using C++ for daily tasks who want to improve their skillset. You don't need to be an expert but you should already have some knowledge of modern C++ and how to use templates to get the most out of this book. Table of ContentsDesired Test DeclarationTest ResultsThe TDD processAdding Tests to a ProjectAdding More Confirm TypesExplore Improvements EarlyTest Setup and TeardownWhat Makes a Good Test?Using TestsThe TDD Process In DepthManaging DependenciesCreating Better Test ConfirmationsHow to Test Floating-Point and Custom ValuesHow to Test ServicesHow to Test With Multiple Threads Cover Title Page Copyright and Credits Contributors About the reviewer Table of Contents Preface Part 1: Testing MVP Chapter 1: Desired Test Declaration Technical requirements What do we want tests to do for us? What should a test look like? What information does a test need? How can we use C++ to write tests? How will the first test be used? Summary Chapter 2: Test Results Technical requirements Reporting a single test result Enhancing the test declaration to support multiple tests Summarizing the results Redirecting the output results Summary Chapter 3: The TDD Process Technical requirements Build failures come first Do only what is needed to pass Enhancing a test and getting another pass Summary Chapter 4: Adding Tests to a Project Technical requirements How to detect whether a test passes or fails Enhancing the testing library to support assertions Should error cases be tested, too? Summary Chapter 5: Adding More Confirm Types Technical requirements Fixing the bool confirms Confirming equality Decoupling test failures from line numbers Adding more confirm types Confirming string literals Confirming floating point values How to write confirms Summary Chapter 6: Explore Improvements Early Technical requirements Getting line numbers without macros Exploring lambdas for tests Summary Chapter 7: Test Setup and Teardown Technical requirements Supporting test setup and teardown Enhancing test setup and teardown for multiple tests Handling errors in setup and teardown Summary Chapter 8: What Makes a Good Test? Technical requirements Making tests easy to understand Keeping tests focused on specific scenarios Use random behavior only in this way Only test your project Test what should happen instead of how Summary Part 2: Using TDD to Create a Logging Library Chapter 9: Using Tests Technical requirements Why build a logging library? How will TDD help build a logging library? What would the ideal logging library look like? Starting a project using TDD Logging and confirming the first message Adding timestamps Constructing log messages with streams Summary Chapter 10: The TDD Process in Depth Technical requirements Finding gaps in the testing Adding log levels Adding default tag values Exploring filtering options Adding new tag types Refactoring the tag design with TDD Designing tests to filter log messages Controlling what gets logged Enhancing filtering for relative matches When is testing too much? How intrusive should tests be? Where do integration or system tests go in TDD? What about other types of tests? Summary Chapter 11: Managing Dependencies Technical requirements Designing with dependencies Adding multiple logging outputs Summary Part 3: Extending the TDD Library to Support the Growing Needs of the Logging Library Chapter 12: Creating Better Test Confirmations Technical requirements The problem with the current confirmations Simplifying string confirmations Enhancing the test library to support Hamcrest matchers Adding more Hamcrest types Summary Chapter 13: How to Test Floating-Point and Custom Values Technical requirements More precise floating-point comparisons Adding floating-point Hamcrest matchers Writing custom Hamcrest matchers Summary Chapter 14: How to Test Services Technical requirements Service testing challenges What can be tested in a service? Introducing the SimpleService project Summary Chapter 15: How to Test With Multiple Threads Technical requirements Using multiple threads in tests Making the logging library thread-safe The need to justify multiple threads Changing the service return type Making multiple service calls How to test multiple threads without sleep Fixing one last problem detected with logging Summary Index Other Books You May Enjoy
Similar books
Test-Driven Development with C++
2022 · EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF