Search code examples
c++visual-c++boost-test

Visual Studio and Boost::Test


I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of my older projects with Unit Tests. My question is -- where do I add the unit test code? The syntax for the tests themselves seems really simple according to Boost::Test's documentation, but I'm confused as to how I tell the compiler to generate the executable with my unit tests. Ideally, I'd use a precompiled header and the header-only version of the boost::test library.

Do I just create a new project for tests and add all my existing source files to it?

Billy3


Solution

  • They way I've added Boost unit tests to existing solutions was to create new projects and put the test code in those projects. You don't need to worry about creating a main() function or setting up the tests. Boost takes care of all that for you.

    Here is a project I put on Google Code that uses Boost for its unit tests.