~/talk

Back to Basics: C++ Testing

Talkat CppCon 2022 · 2022-09-11..09-16· [testing]
slides:none on file

Covers concrete practices: use Google Test (gtest) and gmock with fixtures and parameterized tests, write assertions with expect vs assert and matchers, and prefer setting expectations right before the operation. Shows how to mock return sequencing, use ReturnPointee/lazy actions, pick Nice vs Strict mocks, and create a failing regression test for every bug. Recommends running unit tests at -O0, measuring but not worshipping coverage, and removing flaky or ignored tests.

AI-written summary · about

  1. 0:00Introduction and speaker background
  2. 1:05Why unit testing matters in C++
  3. 2:11Testing levels and the testing pyramid
  4. 3:53Test-driven development fundamentals
  5. 7:27Pros and cons of TDD in practice
  6. 10:01Characteristics of good unit tests
  7. 15:00Common excuses for not testing
  8. 17:28Testing legacy C++ codebases
  9. 18:31Class exercise on file validator tests
  10. 20:37Choosing a testing framework
  11. 21:42Google Test basics and setup
  12. 23:04Mocking dependencies in C++
  13. 25:13Simple example with Google Test
  14. 27:18Verifying test reliability
  15. 28:22Test suites and naming conventions
  16. 29:24Assertions vs expectations in Google Test
  17. 31:58Testing strings and custom types
  18. 33:48Using matchers for better assertions
  19. 36:58Test fixtures and setup/teardown
  20. 39:24Parameterized tests with Google Test
  21. 42:16Mocking techniques and best practices
  22. 46:30Strict mocking and unexpected calls
  23. 47:35Returning values from mocks
  24. 50:02Distinguishing mock calls by arguments
  25. 52:10Matchers on mock arguments
  26. 53:17Setting expectations in tests
  27. 53:38Code coverage and unit test best practices
  28. 57:50Concluding example and C++ game show
  29. 58:11Additional resources and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.