On keeping test logic out of production
I’m currently reading xUnit Test Patterns: Refactoring Test code and so far it’s been a great read.
Here’s some advices on keeping the test logic out of production code. Don’t.
Testing is about verifying the behavior of a system. If the system behaves differently when under test, then how can we be certain that the production code actually works?
The production code should not contain any conditional statements of the
if testing thensort. It should not contain any test logic at all.
- xUnit Test Patterns, chapter 5