Test-Driven Development with C++

Course objectives

After completing this course you will be able to:

  • design object-oriented software for testing - SOLID OOP, Dependency Injection, etc.
  • write unit tests using mock objects (stub and mock)
  • organize tests in a project developed in the TDD methodology
  • effectively implement TDD principles in the project under development

Course syllabus

Introduction to Test-Driven Development

  • Test-Driven Development foundations
  • TDD cycle: Red-Green-Refactor
  • Pros & cons of TDD
  • TDD Kata and Dojo

How to design a testable code

  • SOLID OOP in TDD
    • Single-Responsibility Principle
    • Open/Close Principle
    • Liskov Substitution Principle
    • Interface Segregation Principle
    • Dependency Inversion Principle

Unit tests

  • What is unit testing?
  • Attributes of good unit tests – FIRST
  • Organization of tests in project
  • Unit tests frameworks
    • Google Test
    • Catch
  • Unit tests patterns
    • Four-Phase Test
    • State Verification
    • Guard Assertion
    • Delta Assertion
    • Custom Assertion
    • Behavior Verification

Test doubles

  • Test doubles: Fake, Dummy, Stub and Mock
  • Using Stubs – state verification
  • Behaviour-Based Testing – Mocks
  • Mock libraries
    • Google Mock
    • Trompeloeil

Dependency Injection

  • Using Dependency Injection in TDD
  • Using boost-ext/di library to control dependencies

Refactoring

  • Extraction of classes
  • Extraction of interfaces
  • Rename variables, fields, methods and classes
  • Encapsulation of fields
  • Replace conditional with polymorphism
  • Refactoring towards Design Patterns
  • Refactoring a legacy code

Integration tests and Code-Coverage

  • Integration tests
  • End-to-End functional tests
  • Code-Coverage tools

Prerequisites

Attendance of our Programowanie w języku C++ course or equivalent experience with C++

Course duration

3 days, 8 class hours each
On-site course quote

In-house training course.

Run at your company premises.

Get a quote
On-line course quote

In-house training course.

Delivered live in a virtual classroom.

Get a quote
Upcoming public courses

No scheduled dates available for this course?

Request a course