Improve your code with unit testsOctober 16, 2013 TDD Unit testing
As a way of ensuring buglessness, tests fail miserably.
However, as I realise, writing unit tests has more collateral benefit than direct.
Complicated unit tests indicate complicated code. Instead of spending time on elaborate tests to fit the code, the programmer should refactor the code to be easier to test.
In particular, this means decoupling business logic from user interface or persistence (activerecord cough cough).
You can counter that there’s never time to refactor, but this is the greatest incentive to write tests along the code, instead of “after the code settles down”. And with practice you’ll write better code from the start.
I think tests should not be considered a means of preventing bugs, but of improving application code. Thus, their job cannot be done by a QA engineer and is the sole responsibility of the code’s author.
P.S.: automated acceptance tests without a team of dedicated maintainers? Still a pipe dream.