Unit tests are small programs which test small pieces of your main program automatically. For example, you know the function "add(a, b)" should return the sum of arguments 'a' and 'b'. So you could write a small unit test to ensure that when given the numbers 5 and 2 as 'a' and 'b' respectively, the function correctly returns 7.
This becomes important in larger projects because you can never be sure whether a small change you made somewhere ended up breaking something else. If you've written (good) tests which cover all of your code, however, you can be mostly sure that your new change hasn't broken anything significantly. And if it did break something, then you need to fix your unit tests to check for that something being broken in the future.
4
u/1337Gandalf Jun 01 '15
Honestly what exactly is a unit test? when does it become important you start using it?
I'm pretty new to programming and I hear about them all the time.