Disabling selected boost unit tests?

C

carl

I have made a few boost unit-tests.



#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>

// Boost Test declaration and Checking macros
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/floating_point_comparison.hpp>


BOOST_AUTO_TEST_SUITE(my_tests);
BOOST_AUTO_TEST_SUITE();


BOOST_AUTO_TEST_CASE(test_1)
{

}


BOOST_AUTO_TEST_CASE(test_2)
{

}



BOOST_AUTO_TEST_CASE(test_3)
{


}


Now when I run the unit-test all 3 test are executed. But is it possible
somehow to specify that only test 2 should be run?
 
G

Gert-Jan de Vos

I have made a few boost unit-tests.

#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>

// Boost Test declaration and Checking macros
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/floating_point_comparison.hpp>

BOOST_AUTO_TEST_SUITE(my_tests);
BOOST_AUTO_TEST_SUITE();

BOOST_AUTO_TEST_CASE(test_1)
{

}

BOOST_AUTO_TEST_CASE(test_2)
{

}

BOOST_AUTO_TEST_CASE(test_3)
{

}

Now when I run the unit-test all 3 test are executed. But is it possible
somehow to specify that only test 2 should be run?

Run your test executable like this:

test --run_test=test_2

It is in "User's Guide" -> "Runtime configuration" -> "Run by name" in
the documentation.
 
C

carl

I have made a few boost unit-tests.

#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>

// Boost Test declaration and Checking macros
#include <boost/test/unit_test_suite.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/floating_point_comparison.hpp>

BOOST_AUTO_TEST_SUITE(my_tests);
BOOST_AUTO_TEST_SUITE();

BOOST_AUTO_TEST_CASE(test_1)
{

}

BOOST_AUTO_TEST_CASE(test_2)
{

}

BOOST_AUTO_TEST_CASE(test_3)
{

}

Now when I run the unit-test all 3 test are executed. But is it possible
somehow to specify that only test 2 should be run?

Run your test executable like this:

test --run_test=test_2

It is in "User's Guide" -> "Runtime configuration" -> "Run by name" in
the documentation.




Ok so its not possible to define a unit-test "main" function inside the
unit-test where the test to run is specified manually. I am using Visual
Studion and when I press run it automatically runs all the test. As an
alternative I can setup the run command to accept a runtime argument, but
its rather time consuming compared to outcomment a single line or two in the
source file.
 
C

carl

carl said:
Run your test executable like this:

test --run_test=test_2

It is in "User's Guide" -> "Runtime configuration" -> "Run by name" in
the documentation.




Ok so its not possible to define a unit-test "main" function inside the
unit-test where the test to run is specified manually. I am using Visual
Studion and when I press run it automatically runs all the test. As an
alternative I can setup the run command to accept a runtime argument, but
its rather time consuming compared to outcomment a single line or two in
the source file.

Something like this:

http://www.ncbi.nlm.nih.gov/bookshe...t&part=ch_boost#ch_boost.Disabling_Tests_Expl




Disabling Tests Explicitly in Code

The NCBI extensions include a macro, NCBITEST_DISABLE, to unconditionally
disable a test case or suite. This macro must be placed in the
NCBITEST_INIT_TREE function:
NCBITEST_INIT_TREE()
{
NCBITEST_DISABLE(test_case_name);
NCBITEST_DISABLE(test_suite_name);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top