Our test structure, based on Boost, is as follows:
ProjectRoot/ Library1/ lib1.vcproj lib1.cpp classX.cpp ... Library2/ lib2.vcproj lib2.cpp toolB.cpp classY.cpp ... MainExecutable/ main.cpp toolA.cpp toolB.cpp classZ.cpp ... Tests/ unittests.sln ut_lib1/ ut_lib1.vcproj (referencing the lib1 project) ut_lib1.cpp (with BOOST_AUTO_TEST_CASE) - testing public interface of lib1 ut_classX.cpp - testing of a class or other entity might be split into a separate test file for size reasons or if the entity is not part of the public interface of the library ... ut_lib2/ ut_lib2.vcproj (referencing the lib2 project) ut_lib2.cpp (with BOOST_AUTO_TEST_CASE) - testing public interface of lib2 ... ut_toolA/ ut_toolA.vcproj (referencing the toolA.cpp file) ut_toolA.cpp - testing functions of toolA ut_toolB/ ut_toolB.vcproj (referencing the toolB.cpp file) ut_toolB.cpp - testing functions of toolB ut_main/ ut_main.vcproj (referencing all required cpp files from the main project) ut_classZ.cpp - testing classZ ...
This structure was chosen for an old project, where we had to make individual decisions about which tests to add and how to group test projects for existing source code modules.
Notes:
- A single test code is always compiled separately from the production code.
- Production projects do not reference unit testing code.
- Unit testing projects include source files directly or only reference libraries, depending on what makes sense given the use of a particular code file.
- Unit tests are performed using the post-build step in each ut _ *. vcproj
- All our production assemblies automatically run unit tests as well. (In our build scripts.)
In our real (C ++) world, you need to compromise with each other. obsolete problems, developer convenience, compilation time, etc. I think our project structure is a good compromise. :-)
Martin ba
source share