- Total 0 kr
Workshop: Refactoring for testability in C++
Watch this product and we will notify you once it is back in stock.
Workshop: Refactoring for testability in C++
Hard-to-test patterns in C++ and how to refactor them
The workshop will focus on refactoring code that is tricky to unit test. The difficulty in this context does not lie in the code's inherent complexity when it comes to the logic or domain.
Learning goals
- Get familiar with object oriented design best practices that facilitate writing testable code
- Recognize patterns and practices that result into hard-to-test code
- Learn how to refactor hard to test code (e.g. singletons, hard-coded dependencies, 3rd party libraries, "new" operators etc)
- Learn how to test the refactored code
All of the examples will be rather simple. Instead, the focus will be on patterns technically difficult to unit test because they:
- Require irrelevant software to be tested too
- E.g.: 3rd party libraries, classes other than the one under test
- Delay the test execution
- E.g.: sleeps inside code under test
- Require intricate structures to be copied or written from scratch
- E.g.: Fakes containing a lot of logic
- Require production code to be aware of the test environment
- E.g.:
#ifdef UNIT_TESTS
- E.g.:
- Make changes and/or are dependent on the runtime environment
- E.g.: Creating or reading from files
If the code is testable, writing unit tests can be particularly fun. This is achieved when you are able to write small and atomic unit tests that get executed fast and promptly give developers the feedback they need.
During the workshop we are going to review problematic code snippets inspired by real-life scenarios, show how to refactor them and engage the participants with a hands-on exercise.
Target audience
Software developers and architects working with C++
Prerequisites
- Basic knowledge of object oriented programming principles (in any language)
- Working knowledge of unit testing and mocking concepts (in any language)
- Working knowledge of C++