I haven’t used unit testing outside of classes/courses until yesterday. Usually my code all works or I would test it in some other hacky way (console or debugger). The thing is I never KNEW if all the parts would work until I had everything integrated.
I recently got burned in an interview because i didn’t even know the basics of unit testing well enough to talk about them. So I decided to brush up on it.
This weekend I’m working on a take-home project that a hiring manager gave me and I decided to write tests for some of the methods. It was going okay and was maybe even helpful yesterday (no big deal).
Then today it happened. I was writing a data access method in a style that i haven’t used for a long time (because that’s what the requirements call for). I had no idea if it would work and i was worried. So i wrote a test for it and it passed on the first try. I didn’t think that was right so I spent time writing up other test scenarios. They all passed. Then i made them not pass just to be sure.
I always new unit testing was a best practice but I never wanted to take the time. If nothing else it’s worth writing them just for the piece of mind.