Back to Basics: C++ Testing
summary
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
chapters (29)
- 0:00Introduction and speaker background
- 1:05Why unit testing matters in C++
- 2:11Testing levels and the testing pyramid
- 3:53Test-driven development fundamentals
- 7:27Pros and cons of TDD in practice
- 10:01Characteristics of good unit tests
- 15:00Common excuses for not testing
- 17:28Testing legacy C++ codebases
- 18:31Class exercise on file validator tests
- 20:37Choosing a testing framework
- 21:42Google Test basics and setup
- 23:04Mocking dependencies in C++
- 25:13Simple example with Google Test
- 27:18Verifying test reliability
- 28:22Test suites and naming conventions
- 29:24Assertions vs expectations in Google Test
- 31:58Testing strings and custom types
- 33:48Using matchers for better assertions
- 36:58Test fixtures and setup/teardown
- 39:24Parameterized tests with Google Test
- 42:16Mocking techniques and best practices
- 46:30Strict mocking and unexpected calls
- 47:35Returning values from mocks
- 50:02Distinguishing mock calls by arguments
- 52:10Matchers on mock arguments
- 53:17Setting expectations in tests
- 53:38Code coverage and unit test best practices
- 57:50Concluding example and C++ game show
- 58:11Additional resources and Q&A
related talks
01h 03mBack to Basics: Testing in C++
59mC++ Unit testing - the good, the bad & the ugly
01h 01mBack to Basics: Debugging and Testing in C++ Software Development
01h 01mBack to Basics: Test-driven Development
01h 01mBack to Basics: Unit Testing in C++
53mC++ Unit testing - the good, the bad & the ugly
01h 02mBack to Basics: Unit Tests
01h 07mPragmatic Unit Testing in C++
