Setting up boost unit testing visual studio project

1. Header

#define BOOST_TEST_MODULE TestExample
#include 
using namespace boost::unit_test;

2. Linked library

libboost_unit_test_framework-vc100-mt-sgd-1_46_1.lib

3. Global fixture

struct TestGlobalInitFixture
{
	TestGlobalInitFixture()
	{
		BOOST_TEST_MESSAGE("### Global initialization for testing ###");
	}

	~TestGlobalInitFixture()
	{
		BOOST_TEST_MESSAGE("### Global deinitialization for testing ###");
	}
};
BOOST_GLOBAL_FIXTURE(TestGlobalInitFixture);

4. Fixture

struct BuisnessLogicTestSuiteFixture
{
	BuisnessLogicTestSuiteFixture()
	{
	}

	~BuisnessLogicTestSuiteFixture()
	{
	}
};

BOOST_FIXTURE_TEST_SUITE(TestSuite_BusinessLogic, BuisnessLogicTestSuiteFixture)

5. Test case example

BOOST_AUTO_TEST_CASE(test_should_check_xxx)
{
}

6. run a specific test case example

--run_test=*/test_should_check_xxx

7. change log level

--result_code=no --report_level=no
Advertisements
This entry was posted in C++, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s