Course in Unit Testing in C++ with Catch2

Course in writing C++ unit tests using Catch2

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 Catch2 to write solid unit tests.
This is what you will learn
  • Install and configure Catch2
  • Writing efficient unit tests
  • Dealing with test-data in nested test-cases
  • Being able to formulate assertions and matchers
  • Designing BDD-style tests
  • Writing parameterized tests
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 of Catch2

  • Catch2 at GitHub
  • Download the header-only library
  • Automatic download and configuration using CMake
  • Configuration of CLion to run Catch2

Writing a Test Function

  • Including Catch
  • Defining a test runner
  • Structure of a test function
  • Usage of REQUIRE()
  • Analyzing a failed test


  • REQUIRE vs. CHECK macros
  • Dealing with floating-point comparisons
  • Asserting exceptions
  • Logging


  • What is a matcher?
  • Using REQUIRE_THAT()
  • String matchers
  • Vector matchers
  • Floating-point matchers
  • Predicate lambda matchers
  • User-defined matchers

Test Fixtures

  • Defining a test function with nested SECTION blocks
  • Defining test data (fixture)
  • How nested test cases are executed and handed test data
  • Tagged test cases
  • Special tags

Scenarios and BDD-Style Test Cases

  • Defining a SCENARIO
  • Defining a test case using GIVEN / WHEN / THEN
  • Conjunctions

Parameterized Tests

  • Type-parameterized tests
  • Test-data generators
  • Value generators
  • Predicate-based generators
  • Random value generators
  • User-defined generators

Micro Benchmarks

  • What is a benchmark?
  • Enable benchmarking
  • Defining a BENCHMARK


  • Writing your own main() function
  • Command-line options
  • Invoking the test runner
  • Compile-time configuration properties
  • Command-line options
  • Log reporters
  • CMake integration
NameUnit Testing in C++ with Catch2
Duration1 Days
AudienceExperienced 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
DatePlace Price
2020-02-14Stockholm 11 000 kr
2020-03-06 Stockholm11 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++ 11/14/17 for C++ Programmers3IntermediateShow
Threads Programming using Modern C++3AdvancedShow
Linux Systems Programming using Modern C++3AdvancedShow
C++ Supplementary3Intermediate Show