The Friend-the-tests pattern involves friending test fixture classes from the class under test. Chromium has a macro named FRIEND_TEST_ALL_PREFIXES
that makes this convenient to do.
Note: Friending test classes is usually not the best way to provide testing access to a class. It makes it far too easy to unintentionally depend on the class's implementation rather than its interface. It is better to use a proper testing interface than to friend test classes.
A test needs simple access to the internals of a class, such as access to individual fields or methods.
class Foo { public: // ... public API ... private: FRIEND_TEST_ALL_PREFIXES(FooTest, TestSomeProperty); FRIEND_TEST_ALL_PREFIXES(FooTest, TestABehavior); // or if every test in the suite needs private access: friend class FooTest; };