Modern C++ Programming with Test-Driven Development: Code Better, Sleep Better (Paperback)

Jeff Langr

買這商品的人也買了...

商品描述

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.

商品描述(中文翻譯)

如果你使用C++進行編程,你可能會被忽視。測試驅動開發(TDD)是一種現代軟件開發實踐,可以大大減少系統中的缺陷數量,產生更易維護的代碼,並讓你有信心根據變化的需求改變軟件。但是,推廣TDD的人忽略了C++程序員,直到現在。在這本書中,Jeff Langr將親自教你如何在C++中進行TDD的挑戰和回報。

《現代C++編程與測試驅動開發》是唯一一本全面介紹C++中TDD的書籍,為你提供了關於TDD的一切知識,以及在C++系統中實施TDD所面臨的挑戰和好處。書中的詳細代碼示例將逐步引導你從TDD的基礎知識到高級概念。作為一名資深的C++程序員,你已經在寫高質量的代碼,並且努力維護代碼質量。但其實這並不難。

在這本書中,你將學到:

- 如何使用TDD改進遺留的C++系統
- 如何識別和處理棘手的系統依賴
- 如何在C++中進行依賴注入,這在C++中尤其棘手
- 如何使用幫助TDD的C++測試工具
- 有助於TDD的新C++11功能

隨著你在TDD的掌握程度提高,你將發現如何防止大型C++系統隨著時間的推移變成設計混亂,以及應該避免的特定C++問題。你將了解如何避免測試成為維護負擔,以及如何在不放棄你已經掌握的C++技能的情況下思考TDD。最後,你將看到如何在團隊中發展和維護TDD。

無論你是完全沒有單元測試經驗還是經驗豐富的測試人員,這本書都將引導你掌握C++中的測試驅動開發。

你需要的東西:

- 在Windows或Linux下運行的C++編譯器,最好支持C++11。書中的示例是在gcc 4.7.2下構建的。
- Google Mock 1.6(可免費下載;它也包含Google Test)或其他C++單元測試工具。書中的大多數示例都是使用Google Mock編寫的,但將它們轉換為你選擇的工具並不困難。
- 一個優秀的程序員編輯器或集成開發環境(IDE)。
- 最好使用cmake。當然,你也可以使用自己喜歡的make。每個項目都提供了CMakeLists.txt文件。示例是使用cmake 2.8.9版本構建的。
- 書中的示例使用了幾個免費的第三方庫作為基礎,包括:
- cURL
- JsonCpp
- Boost(filesystem、date_time/gregorian、algorithm、assign)

幾個示例使用了Boost頭文件/庫。只有一個示例使用了cURL和JsonCpp。