BOOST_AUTO_TEST_SUITE(スイート名),BOOST_AUTO_TEST_SUITE_END()で囲めば良い.
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include <boost/test/unit_test.hpp> #include <boost/test/unit_test_suite.hpp> bool isOdd(int n) { return n % 2 != 0; } bool isEven(int n) { return n % 2 == 0; } BOOST_AUTO_TEST_SUITE(OddTest) BOOST_AUTO_TEST_CASE(oddTest) { BOOST_CHECK_EQUAL(isOdd(0), false); } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE(EvenTest) BOOST_AUTO_TEST_CASE(evenTest) { BOOST_FAIL("Fail"); } BOOST_AUTO_TEST_SUITE_END()
これを実行すると,こんな感じ.
$ ./main --report_level=detailed Test suite "Master Test Suite" failed with: 1 assertion out of 2 passed 1 assertion out of 2 failed 1 test case out of 2 passed 1 test case out of 2 failed 1 test case out of 2 aborted Test suite "OddTest" passed with: 1 assertion out of 1 passed 1 test case out of 1 passed Test case "oddTest" passed with: 1 assertion out of 1 passed Test suite "EvenTest" failed with: 1 assertion out of 1 failed 1 test case out of 1 failed 1 test case out of 1 aborted Test case "evenTest" aborted with: 1 assertion out of 1 failed
オプションに,--report_level=detailedを入れないとここまで詳細に出ない.他にも自動的に組み込まれるオプションがいくつかある.--show_progress=yesでテストの進捗を表示したり.--helpで確認可能.
0 件のコメント:
コメントを投稿