Test-Driven Development in C++ - Unit Testing and Refactoring for Agile Software Development

Contact Us for Dates
2 days practical workshop for up to 12 people.

Contact us for Onsite Price

The Test-Driven Development in C++ course presents a number of modern practices for developing code based on an iterative and incremental development lifecycle. Agility and predictability are two qualities often missing from software development. A test-driven approach, in which design is grown and code delivered incrementally according to functionality or risk, forms the basis of the construction phase of an iterative and incremental development. The use of unit testingprovides confidence in existing code and supports the ability to refactor code as development unfolds.

Layout

The training course combines lectures with practical exercises that help the delegates to put what they have learned on the training course into practice. The exercises specifically build on what has been recently taught and are built up as the training course progresses.

Training Course Objectives

  • Appreciate the benefits of a continuous and iterative approach to design and delivery
  • Recognise the purpose and practice of refactoring in keeping a system supple and adaptable
  • Know how to build up a set of tests and simple test frameworks for units of code
  • Understand the consequences of dependency management on testing and code quality

Who it is for

The course is suitable for software developers experienced in C++ and familiar with object-oriented principles and practices.

Training Course Prerequisites

  • Any previous exposure to unit testing tools or agile development concepts is beneficial but not essential.

Chapters

Chapter 1 Agile Development Microprocess

  • Traditional versus agile development processes
  • Iterative and incremental development
  • Informal and continuous design
  • The role of refactoring
  • Refactoring versus other code changes
  • Extreme Programming
  • Test-Driven Development

Chapter 2 Testing in Principle

  • Traditional view and reality of testing
  • Driving development through testing
  • Testing early, often and automatically
  • Testing versus debugging
  • White-box versus black-box testing
  • Functional versus operational testing

Chapter 3 Basic Unit Testing in Practice

  • Test plans versus test code
  • Use of Assert
  • Testing at the interface
  • Testing the simplest things first
  • Testing incrementally
  • Testing correctness of failure

Chapter 4 Refactoring a Test Harness

  • Common unit test frameworks (xUnit and Boost)
  • Refactoring to a simple framework
  • Test cases, test suites and test runners
  • Throwing exceptions on failure
  • Continuing tests after failure
  • Customising assertions
  • Testing correctness of exceptions

Chapter 5 Test-Writing Techniques

  • Red, green, refactor
  • None to one to many
  • Faking it
  • Telling the truth
  • Isolated and short tests
  • Refactor common fixture code
  • Declare, prepare, assert
  • Test by method, state or scenario
  • Asserting compile-time constraints

Chapter 6 Common Refactorings

  • Renaming variables, functions, classes and headers
  • Restructuring class hierarchies by extracting interface classes, base classes and derived classes
  • Partitioning classes by extracting classes and functions
  • Changing private representation

Chapter 7 Decoupling Techniques

  • Unmanaged dependencies
  • Test-driven decoupling
  • Layering
  • Eliminating cyclic dependencies
  • Mock objects
  • Eliminating Singletons, statics and other globals
  • Testing I/O