Make it part of your workflow. Test often and don’t get test for good things. Test for errors, bad input, … Also test for performance. Oh, you wrote a sweet sweet function … how well does it perform when ran 10 times? 100x? 100000000000x?
To help you on your way, here is a short set of videos on Magento 2’s PHPUnit testing.