C++ Fundamentals: Unit Testing
summary
Shows concrete C++ unit testing patterns using Google Test: writing TEST, TEST_F/TEST_P fixtures and parametric cases, and using mock expectations to control dependencies and capture arguments. Demonstrates TDD flow (write failing test, implement minimal code), refactoring toward dependency injection, and measuring coverage — warns that 90% coverage can be meaningless without meaningful assertions. Example units include a filename validator and a custom vector iterator; tests expose real bugs and guide safe refactors and checks across -O0 vs -O2 builds.
AI-written summary · about
chapters (18)
- 0:00Introduction to unit testing
- 1:07Why unit testing matters
- 3:41Unit vs integration testing
- 6:06Test Driven Development basics
- 9:00Reducing fear of code changes
- 10:22Dependency injection for tests
- 12:51Refactoring for testability
- 14:16Benefits of unit tests
- 17:31Maintainable and trustworthy tests
- 20:23Writing good test cases
- 26:52Test case design exercise
- 30:02Google Test framework overview
- 33:15Assertions in Google Test
- 38:18Fixtures in Google Test
- 40:25Parameterized tests
- 44:20Mocking dependencies
- 52:53Best practices summary
- 55:25Concluding example and Q&A
