Home > The Unit Test Framework > User's guide > Runtime configuration > Run by name
PrevNext

Running specific test units selected by their name

In regular circumstances test module execution initiates testing of all test units manually or automatically registered in master test suite. The UTF provides an ability to run specific set of test unit as well. It can be single test case, single test suite or some combination of test cases and suites. The tests units to run are selected by the runtime parameter run_test. In the following examples I select tests to run using command line arguments, but the same filter expression can be used as an appropriate environment variable value.
通常,測試模塊執行初始化手動或自動註冊在主測試套件中的所有測試單元。 UTF 提供了運行指定測試單元集合的能力。 可以是單個測試用例,單個測試套件或測試用例和套件的組合。 要運行的測試單元是參數運行時參數 run_test 選擇的。 在下面的例子我使用命令行參數選擇要運行的測試,同樣的過濾表達式也可以通過環境變量值來設定。

Filter expressions are specified in a form a/b/c, where a, b and c are filters for corresponding levels of test tree. Symbol '*' can be used at the beginning, at the end and as the level filter itself as an asterisk. Symbol ',' is used to create list of test units residing on the same level in test tree.
過濾表達式使用 a/b/c 格式來指定,其中 a、b 和 c 是測試樹對應級別的過濾器。 符號 '*' 可以用在開始或結尾,或在級別過濾器中作為星號。 符號 ',' 用於在同級別的測試樹中創建測試單元列表。

Let's consider following test module consisting from several test suites and test cases.
讓我們考慮下面由多個測試套件和測試用例組成的測試模塊。

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

BOOST_AUTO_TEST_CASE( testA )
{
}

BOOST_AUTO_TEST_CASE( testB )
{
}

BOOST_AUTO_TEST_SUITE( s1 )

BOOST_AUTO_TEST_CASE( test1 )
{
}

BOOST_AUTO_TEST_CASE( lest2 )
{
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE( s2 )

BOOST_AUTO_TEST_CASE( test1 )
{
}

BOOST_AUTO_TEST_CASE( test11 )
{
}

BOOST_AUTO_TEST_SUITE( in )

BOOST_AUTO_TEST_CASE( test )
{
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()

PrevUpHomeNext