tags:

views:

75

answers:

1

I have a project of 50+ .H/.CPP files/classes. I would like to test every class with its own test case, which will include methods for testing of different aspects of every class. My classes are located in different directories, like this:

/project
  /include
    /SuperModule
      Foo.h
      Foo.cpp
      ..
    Alpha.h
    Alpha.cpp
    ..
  /test         // I assume that my tests shall be here
  main.cpp
  Makefile

I would like to use boost::test as a unit-testing framework. How should I organize my files, how shall I name them, etc. Some hint or a link or a suggestion will be appreciated. Thanks.

+1  A: 

We are using boost::test in a similar layout. Our layout is -

/project
  /include
    /SuperModule
       /Foo
        foo.c
        foo.h
        /foo_unittest
            foo_unittest.c   // note - no separate header file is required 
                             // for boost::test unit test.exe program.

Basic layout rule is to put the unit test for a class in a sub-directory named "foo_unittest" after the class in the same directory as the source code. The advantage to this naming is

  1. The source code and the directory are stored next to each other. So by simple inspection you can see if you have written the unit test or not.
  2. Also, when you copy the source code, it is easy to copy the unit test at the same time.

As our projects are not overly complex (30-50 major classes), this system works for us. If you are running larger projects, I don't think this would be an optimal solution.

photo_tom