main関数はリンクするライブラリの中に実装されている。
#include "stdafx.h" #include <boost/test/unit_test.hpp> void my_test_function1() { ... } void my_test_function2() { ... } boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { boost::unit_test::test_suite* test = BOOST_TEST_SUITE("testsuite_name"); test->add(BOOST_TEST_CASE(&my_test_function1)); test->add(BOOST_TEST_CASE(&my_test_function2)); return test; }
MSVCの場合
MSVCであればリンカの設定の代わりに以下のコードを埋めておくことができる
#ifdef _MT #ifdef _DEBUG #pragma comment(lib,"libboost_unit_test_framework-vc71-mt-sgd.lib") #else //_DEBUG #pragma comment(lib,"libboost_unit_test_framework-vc71-mt-s.lib") #endif//_DEBUG #else//_MT #ifdef _DEBUG #pragma comment(lib,"libboost_unit_test_framework-vc71-sgd.lib") #else //_DEBUG #pragma comment(lib,"libboost_unit_test_framework-vc71-s.lib") #endif//_DEBUG #endif//_MT
ビルド後のイベントに以下のコマンドを追加しておくと
ビルドのたびにテストが起動。
ビルドのたびにテストが起動。
"$(TargetDir)$(TargetName).exe" --log_level=messages --build_info=yes (次行に続く) --result_code=no --report_level=short --catch_system_errors=no
添付ファイル