How to execute specified test suites in boost.test library

浪子不回头ぞ 提交于 2019-12-11 05:48:48

问题


I am using Boost.Test library for implementing unit test cases in C++. Suppose I have two suites such as

BOOST_AUTO_TEST_SUITE(TestA)
BOOST_AUTO_TEST_CASE(CorrectAddition)
{
BOOST_CHECK_EQUAL(2+2, 4);
}

BOOST_AUTO_TEST_CASE(WrongAddition)
{
    BOOST_CHECK_EQUAL(2 + 2, 5);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE(TestB)
BOOST_AUTO_TEST_CASE(CorrectAddition)
{
bool ret = true;
    BOOST_CHECK_EQUAL(ret, true);
}
BOOST_AUTO_TEST_CASE(WrongAddition)
{
    BOOST_CHECK_EQUAL(2 + 2, 5);
}
BOOST_AUTO_TEST_SUITE_END() 

and I would like to run only say suite 'TestB', how shall I execute it. I really thank for your time and help. Sorry if this question is been posted or documented else where.


回答1:


Assuming you are using the library-supplied main entry point, command-line parsing, etc., and haven't rolled your own, you can select specific test suites and test cases by name or pattern via a command-line switch at run time.

See this page in the documentation for a good example.



来源:https://stackoverflow.com/questions/3615979/how-to-execute-specified-test-suites-in-boost-test-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!