Classes With Test Method

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.


EditText of this page (last edited November 6, 2002) or FindPage with title or text search