Another way of colocating test and code under test,
is to add a test method to a functional class.
class ClassThatReallyGetsUsed {
public:
...
public:
void test() {
...
}
};
Colocation is good, up until the point where
the amount of test code starts distracting you from the actual code.
I nevertheless like using this pattern in a more restricted way:
even when I have created a separate test class,
my convention is to give it a test() method.
This allows separate test classes and
ClassesWithTestMethod
to be managed using the same
TestCollector.