Using the friend method, the declaration will depend on the name of the test class, so if you ever change its name, the declaration must also be changed. In addition, I use Unittest ++, so the actual name of the test calss is formed by a macro.
Then the method with the definition is less hassle. Also, I would just put the definition as a global compiler option instead of the way you show, e.g.
gcc -DUNIT_TESTING_ON #ifdef UNIT_TESTING_ON public:
Anyone who reads this also sees what the purpose is, it is more clear than looking for a friendβs definition to understand why you made him a friend.
stijn source share