Florian Lindner
Hello,
I use boost.test precondition in an MPI application to disable test at ranks != 0 if they do not use MPI:
boost::test_tools::assertion_result isMaster(boost::unit_test::test_unit_id) { return precice::utils::Parallel::getProcessRank() == 0; }
Is this compile time condition? If yes you can use enable_if decorator. Is this identified by command line parameters? If yes you can use enabled/disabled decorator and switch on the test cases using --run parameter. If this is actual runtime condition, which depends on something outside of unit test, this is not a good unit test design IMO, since it make unit test behavior non deterministic. If you really want to do something like this, you can define global fixture and enable/disable test units manually. There is no strait forward public API to access test unit by name like "a.b.c", but you can easily do it yourself using framework::master_test_suite, framework::get and test_suite::get interfaces. Each test unit has public property p_run_status, which you can update to enable/disable test unit execution.
BOOST_AUTO_TEST_SUITE(NearestNeighborMapping)
BOOST_AUTO_TEST_CASE(ConsistentNonIncremental, * boost::unit_test::precondition(isMaster)) {...}
That works perfect, I just don't like that sipped test are reported as errors. Example with all tests deactivated:
I agree the documentation is somewhat misleading in presenting precondition decorator along with enable/disable decorators. Former is similar to failed dependency and is treated as an error if failed. Later is setup time test tree organization tool. Gennadiy