Unit test
-
HOW TO WRITE A UNIT TEST
Let’s start with making this one thing perfectly clear. Unit tests validate behaviour. NOT code. Sounds simple enough, but is it? To start with, the function you test is a black box. When you write the test, you don’t know what the code looks like. And that is important, because the reason unit tests exists is to tell you when your code stops doing what it is expected to do. It doesn’t matter how it does it, or how many times you change it, as long as it delivers the correct result. They are not a code review. Which means that you are free to refactor the s**t out of…