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
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.
You can put your tests to the same project, but mark files with tests as Excluded from Build for Release and Debug configuration and create new project configuration for unit tests. Here is an article about using Boost Test in Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With