Course in Unit Testing in C++ with Google Test

Course in writing C++ unit tests using Google Test

Do not write one single production code without having a associated unit-test. In this course we go straight to the point and teach you how to use Google Test to write solid unit tests.
This is what you will learn
  • Download, install and compile Google Test
  • Writing unit test functions
  • Writing tests using fixture classes
  • Configure JetBrains CLion to run tests within the IDE
  • Genereate XML output for further processing, such as HTML reports in Jenkins
Course Contents

Unit Testing and TDD

  • Type of tests
  • What is a unit test
  • Write F.I.R.S.T. tests
  • Structure of a unit test
  • Given-when-then style
  • What is test driven development (TDD)

Installation and Compilation of Google Test

  • GTest at GitHub
  • Download and building gtest explictly
  • Downloading and building automatically using CMake
  • Configuration of CLion to run gtest

Writing Test Functions

  • Using the gtest test driver
  • Writing a TEST() function
  • Failing a test
  • Expectations vs. assertions
  • Relational checks
  • Checking strings and native strings
  • Checking for thrown exceptions
  • Checking floating-point results

Test Fixtures

  • Test life-cycle
  • Defning a fixture class
  • Setup and teardown operations
  • Handling fixture data

Parameterized Tests

  • Setting up a value-parameterized test
  • Parameter value generators
  • Setting up type-parameterized test
  • Different ways to instantiate parameterized tests
  • Type fixtures

Death Tests

  • Checking for abnormal program termination
  • Death test checks
  • Death test predicates
  • Checking for non-zero exit code
  • Checking for raised signals such as SIGSEGV or SIGFPE

Command-Line Usage

  • Running gtest on the command-line or inside a shell script
  • Selection a sub-set of the tests to run
  • Sample test filters
  • Repeated tests
  • Disabling selected tests
  • Generating XML output for further post-processing

Life-Cycle Methods

  • Runing code before and after test each test-function
  • Runing code before and after test each test-group
  • Runing code before and after test each test-suite

Mock Objects

  • How to deal with dependent object that is not the target for a test
  • Using fake objects
  • What is a mock object
  • Setting up Google Mock (gmock)
  • Setting up a test using mock objects

Overview of Other Test Frameworks

  • Google Benchmark
  • Catch2
  • Doctest
  • CppUnit
Name Unit Testing in C++ with Google Test
Duration1 Days
Audience Experienced C++ programmers
PrerequisitesKnowledge about Modern C++
  • GCC/G++ compiler, version 8 or later
  • Jetbrains CLion IDE
  • Ubuntu Linux @ VirtualBox or WLS @ Windows-10
Course Dates
2020-02-14Stockholm11 000 kr
2020-03-06Stockholm 11 000 kr
2020-03-27 Stockholm11 000 kr
2020-04-17 Stockholm11 000 kr
2020-05-08 Stockholm11 000 kr
2020-05-28 Stockholm11 000 kr

Same-Company Discout

We offer a 20% discount for additional participants from the same company and at the same course date. Read more here.

Teaching Language

Our printed course material is always authored in English. The oral presentation in our classrooms is generally in Swedish, unless all participants agree to that we perform the course in English.

On-Site Course

If you order an On-Site course, we will come to you and hold the course in your office. The price is determined by our price model and is based on the number of course days, number of participants and any travel and lodging.

Read more about out price modell and term of sales here.

Related Courses
C++ Supplementary3IntermediateShow
Threads Programming using Modern C++3 Advanced Show
Linux Systems Programming using Modern C++3AdvancedShow
C++ 11/14/17 for C++ Programmers3 IntermediateShow