Definition
A kind of AutomatedTest, though some would say a better name is DeveloperTest
“Unit” casually refers to low-level test cases written in the same language as the production code, which directly access its objects and members.
Under the strict definition, for QA purposes, the failure of a UnitTest implicates only one unit. You know exactly where to search to find the bug.
Links:
- Catch2
- Qt Test
- Google Test (includes Google Mock)
- Mock’s Aren’t Stubs
Unit test private functions
It is preferable to test through the public interface. If your class X has a lot of code in the private member functions then it might be worth extracting a new class Y which is used by the implementation of class X. This new class Y can then be tested through its public interface, without exposing its use to the clients of class X. (stack overflow)