Back to Basics: C++ Testing - Amir Kirsh - CppCon 2022

In this lecture, Amir Kirsh delves into the fundamental principles of C++ testing, highlighting the importance of testing in software development and providing practical insights into effective testing strategies and techniques.

Key takeaways
  • The main problem with testing in C++ is that the API is too fluid and difficult to define.
  • Unit testing is valuable for ensuring that code works correctly, and is not just testing the mock.
  • Tests should be isolated from each other and not rely on specific implementations.
  • Code should be designed to be testable, with separate layers and interfaces.
  • Mocking dependencies is important for unit testing, as it allows for isolation of the code being tested.
  • Tests should be written before the code, as this helps to ensure that the code is designed correctly.
  • The testing pyramid, with unit tests, integration tests, and system tests, is a good way to approach testing.
  • Code should be reviewed, especially tests, to ensure that it is correct and maintainable.
  • Time should be managed to ensure that tests are not too long or complex.
  • Code should be written with testability in mind, and should be decoupled from other parts of the system.
  • Testing should be done with random input, to ensure that the code works correctly under different conditions.
  • The idea of TDD (Test-Driven Development) is to write tests before writing code, to ensure that the code is correct and maintainable.
  • The main goal of testing is to ensure that the code works correctly, and to catch bugs early.
  • The concept of “bed tests” is a bad practice, as it means that the test is not testing the code correctly.
  • A bug is not necessarily a bad thing, as it can be caught and fixed early in the development process.
  • A good test should be easy to understand and maintain, and should be written before the code is written.
  • Testing is an important part of the development process, and should be done regularly.
  • Code review is important for testing, as it allows for review of the code and identification of bugs.
  • The idea of a “testing fixture” is to have a base class that provides a setup and teardown for tests.
  • The idea of “test driven development” is to write tests before writing code, to ensure that the code is correct and maintainable.
  • A good code test should be easy to understand and maintain, and should be written before the code is written.
  • The idea of “test driven development” is to write tests before writing code, to ensure that the code is correct and maintainable.
  • Code review is important for testing, as it allows for review of the code and identification of bugs.
  • A good test should be easy to understand and maintain, and should be written before the code is written.