Embracing Test Driven Development.
I do not know about you but the first time I heard about tests in software development, I fretted. The mental picture I had was the same, the one built up by my school days. Back then everyone hated tests in school and I wasn’t any different.
Human nature automatically hates what it does not know. I too got biased on hearing about tests. Grudgingly I asked, why are they even useful? Can’t we skip them? I asked a multitude of questions, not with the intention of learning but of discrediting the whole idea.
Surprisingly with every question came a satisfactory answer. Every answer made more sense. After a while my curiosity was quenched by the answers. They are very many benefits to testing and why I embraced the test driven development practice.
The most stunning of them all is the aspect of quality assurance. Few measures are known that can guarantee code quality without tests being involved.
With test driven development I must admit everything sounded weird. Tests, that must fail? Test must fail because of no function yet. Trust me all that sounds incomprehensible when you first hear it.
With time I have been able to appreciate the beauty of the practice and the many virtues that come from it. I have regretted at why this wasn’t the first software development skill, I learnt.
I have began with the PyUnit a python testing framework. The use of the ‘unittest’ class broadened my knowledge of Object Oriented Programming. For with this class, every test had to be a class method.
With time I have learned to prefer Pytest to Nosetests but they are both equally fascinating. I have learnt to use test suites in conjunction with other tools such as coveralls, coverage and travis.
I have learned how crucial the practice is in the big picture. How tests improve class and function quality. How they are the basis of builds in the Continuous Integration models, which is part of the Agile methodology.
With this practice a lot of time is saved for having the relevant tests upfront and fleshing out the functions comes easy. That is easier than debugging a 500 line function and tweaking both the test and the function to have them harmonize.
I am looking at mastering Mock Objects and have experimented with Mocha and Chai which are Javascript libraries. Are you familiar with Test Driven Development? Do you have tests for your code? You know what they say about untested code. It is broken code.