Unit testing -- it's a lot of work. There's no doubt about it, it can be a long time before unit testing seems like it is worth it. I know for a good long while I thought unit testing was for the birds, but I think this week's lecture may have changed my mind.
Let's see -- what is useful about unit testing, especially when it comes to Python? Unit testing is very useful for having a good developed program, and especially when working in teams. Unit testing allows you to make small changes to your code and check that it still works, which can be very useful when dealing with large codes or multiple programmers. This can save a lot of time and headache, which can be very useful long-run.
Unit tests also really help you understand exactly what your program is all about. Yes, yes, I know -- you wrote it. Who knows it better than you yourself? But you can't claim to know all the inner workings of every Python class you call forth, or what exactly your code is doing every moment of its run. Unit tests make sure you have a better idea of the general idea of your program, and help you keep track of everything that could possibly need fixing. Unit tests give you a lot of immediate feedback, and really help define your code.
Unit testing helps keep your code concise and of quality. It's something you may not want to do, but it is a good habit to get into and will help you a lot if you manage to keep it up!
No comments:
Post a Comment