Making unit tests your primary attention point
Blog: Capgemini CTO Blog
Test-driven development and behavior-driven development ensure that testing plays an important role in your software development. I really like the concepts that bridge the gap between software developers and non-technical roles (e.g., business analysts, functional designers, etc.) Using unit testing improves the quality of your delivery and can help you keep your documentation up to date.
One other thing that has really got my attention in the last couple of years is live unit testing. Live unit testing is part of your Visual Studio Enterprise edition but if you don’t have that, NCrunch delivers the same thing. Even though I have a VS Enterprise license, I still bought the NCrunch license. It is quick, easy to set up, and efficiently delivers as per my requirements. For best performance, you need a heavy-duty machine – but all developers should have that anyway, right?
Live unit testing gives me insight into the results of my development work. This is especially true if I am refactoring a bit of code. If the original code is backed by proper unit tests, you will get immediate feedback on whether your refactoring works or not. I find it very comfortable to check the visual indicators in the margin of the editor for failing and succeeding unit tests. If the marker is green, I’m good to go. If it’s red, the code needs attention. The colors tell me everything
Unit tests also give you code performance metrics. The visual indicators indicate the success or failure of the unit test, but will also give the performance metrics. You will see immediately – even while typing – what the effect of your efforts are on the performance of your code.
For me, that is magic. Even before saving your code, the editor gives feedback about these metrics. It is very easy to try a different approach if a previous one didn’t give you the results you were looking for.
The big picture here is the evolution of the tools that we give our developers. Developers can be extremely productive and the tools to help them with that are readily available. One might need bigger and faster machines to make good use of them, but the proper tools are excellent value for money. A fast machine and, in this case, live unit testing make a much more productive developer. Investment in those tools is always a good idea.
Give Live unit testing a go. It really has changed my perspective on unit testing and helps in my day to day work.