News for hackers. Stuff that matters.
Re:Ask HN: What is a unit test? by AnimalMuppet on Monday October 01, 2018 @01:47PM (#18115002)
It's amazing the stuff I've found with unit tests. Two from the top of my memory: a semaphore deadly embrace, and using a pure virtual function in the destructor of a base class.

Then there's the confidence of knowing, with fairly high accuracy, whether my changes broke anything. Then there's the value of finding out very quickly whether any of my co-workers' changes broke anything.

What are they? They are tests that you can run all the time, because they're fast. They test all (hopefully) of the external behaviors of your class. (That is, they test the behaviors that a caller should be able to count on. They don't test the internal details, because the user shouldn't care if you change those.)

Maybe the best way to learn them is to work with people who use them well - more apprenticeship than book learning.

There are no comments on this comment yet.