There is a lot of knowledge out there on automated testing. You can learn how to write unit tests, do TDD, construct test pyramid, use one particular testing framework or another.

What I have been missing is materials on sustainable testing: so writing automated tests that not only will do their job today, but will also defend themselves against change over time and will not cost a fortune to maintain. Inspired by Scott Meyers formula for a few of his books, I created a repository of riddles showcasing common issues with test sustainability, and offering remedies.

Many of the riddles were inspired by observations in projects I had a pleasure to work on; and even tested in form of workshops on my colleagues. If you have any suggestions or feedback on any content on this site, 3c6120687265663d226d61696c746f3a666565646261636b407375737461696e61626c6563707074657374696e672e636f6d3f5375626a6563743d5375737461696e61626c6520432b2b2054657374696e67223e67657420696e20746f756368213c2f613e.

Each riddle shows a code snippet: a chunk of production code and the corresponding test code. Don't nitpick on the production code, though, that's not why we're here. Challenge the test code. It will look pretty decent at first glance. But it will always have a weakness, which will reveal itself over time, e.g. in response to a change in the system, which may lead to loss of test coverage or expensive maintenance.

The code is in C++ and uses GTest & GMock frameworks. All of the riddles assume some understanding of them. However, only some of the principles are specific to the Google frameworks - most of them apply just as well to other frameworks or languages even.