C++ Test-Driven Development

All developers want to build good quality software but not all developers test their software as they go along. Why not? A common explanation is "I don't have time to write tests!" The more pressure they feel, the fewer tests they write. This leads to less accurate and stable code, less productivity, less confidence and, ultimately, more pressure. It's a vicious cycle.

This course is designed to help you break out of the cycle by embracing unit-testing and, in particular, test-driven development. We will introduce the techniques and the tools necessary to prove your code as you go along.

The course makes use of GoogleTest during the labs and demos. If you’d like to use a different test framework instead, that can be arranged.

Duration

2 days

 

Prerequisites

  • At least 3 months C++ programming experience

What you'll learn

  • Writing tests using GoogleTest
  • Using assertions and matchers
  • Adopting a test-driven approach to development
  • Using stubs and mock objects

Course details

Getting Started with Unit Testing

  • Setting the Scene
  • Getting Started with GoogleTest
  • Implementing Tests

Using a GCC Toolchain

  • Planning and Organizing Tests

Industrial-Strength Unit Testing

  • Telling GoogleTest How to Display Objects
  • Testing for Exceptions
  • Using gMock Matchers

Parameterized Tests

  • Value-Parameterized Tests
  • Value-Parameterized Tests, Going Further
  • Typed Tests
  • Type-Parameterized Tests

Test-Driven Development

  • Effective Test-Driven Development
  • Refactoring Techniques
  • Types of Test

Test Doubles

  • Making Code Testable
  • Overview of Test Doubles
  • Using Stubs
  • Getting Started with Mocking
  • How to do Mocking using gMock