Unit testing and TDD

By | 26 January, 2013

So, you are not unit testing your sofware and you want to be called developer. Interesting… 😀

Unit testing is a practice which is not new at all. It has been there for the last years. However, my feeling is that it is something that looks awesome in books, everyone states that they know how to unit test software, but in practice, is not always applied, or not in the way it should.

When we discover or are told about a bug in our software, typically one can see lots of developers scanning the code, implementing a fix without paying too much attention to the side effects of this change in other parts of the app, and immediately test the app using the user interface. Obviously, this is WRONG. In contrast, the right approach would be, trying to reproduce the bug with a test, and make it fail. Then fix the code and then re-run the test. The benefits of this approach is that we are protecting ourselves from this bug for the future. If tomorrow we have to change other part, we can run this test and make sure that this bug is not coming back again. And only with a click and in a few seconds!

In conclusion, this is only one of the advantages of using unit testing, but there are a lot. There are dozens of books out there to read and learn how things should be done. To begin with, you can start with this walkthrough about unit testing and TDD in .NET MVC framework:

Oh, so you think that writing unit test is working twice. Whatever man… Tell me this when you have to do overtime trying to find out where the bugs are… 😛

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Leave a Reply

Your email address will not be published.