Unit tests seem to be like flossing - everyone says you should do it... but do you really?
Unit testing has been on my development todo list for the past while and despite a few false starts, I have not really managed to get to grips with it. Today I decided to change all that and spent the day thrashing out some tests and here are some of my initial thoughts:
Now, with that out the way, you basically have 4x types of testing to my mind:
Now, my path to testing has been driven primarily by need. Working on applications that run in multiple markets, with multiple configurations in the cloud means that with each new market or entity, you have one more application area to test, and it quickly gets out of hand when you are running UAT and Production environments with agile release schedules. As such, I have gotten to the point where I need tests to back my team and I up when it comes to quality control. There just is not enough time to test every possible area with every code change and have the confidence you should that you have not broken something somewhere. While I am ashamed to admit it, I have been cowboy coding for far too long. Not cowboy cowboy, but the reality is that with the fast pace of development these days, one needs to have the following backups:
Something to keep in mind when testing is to have a 'validation' mindset. What I mean by that is, you need to be thinking about what you are testing with a hygenic mindset. Basically, if you have a round hole, you are specifying what fits in that round hole as well as specifying what does not fit. Essentially, you are being pedantic to some level.
Something that does come to mind as one goes through this is that testing is not very straightforward. It is kind of obscure at times and seems strange to get your head around. But, even if you find it uncomfortable, stick with it, because, I think, even the process of going through this, and getting yourself to think about your code from a different perspective will on some level, improve your code regardless of how the tests go.