Unit Testing

Unit testing is a software testing technique where individual units (usually functions or class methods) of a software system are tested in isolation to ensure that they are functioning correctly. There tests are fully automated and should focus on testing the behavior of the unit, typically with a set of predefined inputs and expected outputs. (But there are methods to make those inputs randomized, see property-based testing.)

The purpose of unit testing is to catch defects early in the development process and to provide a safety net for code changes, ensuring that new code does not break existing functionality. Unit testing is an important practice in software development and is often integrated into continuous integration and delivery workflows.

We talk about testing a lot on this blog. Have a look at some existing articles on this topic:

The Most Common Unit Testing Mistakes
A look at some (potentially) controversial ideas on how to get more value out of your tests. (And how to avoid wasting time and money on useless unit tests.)
The Beginner’s Guide to Property-based Testing
Property-based testing is a type of software testing that allows us to test systems by defining properties (or invariants) that should hold true for a range of inputs. I imagine that reading the word “invariant” makes you shiver. Are we back in class? Will there be math in this article? Fear not!