Hacker News new | ask | show | jobs
by fuzzylizard 5247 days ago
I agree with only one point in the article; the ability to delete tests. Tests of all kinds should be living, breathing code, just like the code in the rest of your application. As such, tests, like production code, can become outdated and obsolete and need to be updated, changed, and sometimes deleted.

However, I do not agree with the idea that tests are evil. If your tests are failing, or breaking regularly, or are hard to write, then your tests are trying to tell you something. Tests are a direct mirror of the state of your code. If your tests are brittle and hard to manage, don't delete the tests, fix your code. If you need to instantiate a tonne of objects in order to make your tests work, fix your methods dependencies and learn to test your methods in isolation of its dependencies.

Any production code needs tests, this is non-negotiable in today's development eco-system. But I get tired of people who do not understand the purpose of tests complaining that tests are evil. If there is a problem with your tests, then your tests are telling you there is a problem with your code. Clean up your code in order to clean up your tests. However, remember that as code changes, your tests will need to change as well. It is okay to edit, delete, change tests to reflect the current state of the application. Just change the tests first to express how you want to interact with a specific bit of code and then change the code, not the other way around.