Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 554
Billy ONeal Avatar asked Aug 08 '09 16:08

Billy ONeal


2 Answers

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.

like image 158
Ferruccio Avatar answered Oct 21 '22 01:10

Ferruccio


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.

like image 6
John Avatar answered Oct 21 '22 02:10

John