When to use manual registration in the Boost Test library?

I always used automatic registration with the Boost test. Now I wonder, what is manual registration intended for? Are there any cases that automatic registration cannot handle?

An additional remark, this time I will use the turtle for ridicule.

Edit: It seems that my question is incomprehensible, more precisely:

  • When should you use manual registration instead of automatic registration?
  • Why should I do this? What are the real-life situations for which automatic registration is not enough?
+4
source share
4 answers

In accordance with the documentation

To alleviate this problem, UTF provides tools for automated (on-site) creation of test cases and registration in the test tree. These objects sacrifice some commonality and work only for selected signatures of test functions.

However, I have never encountered a situation where the automatic registration of the test failed. For instance. you can test functions (with BOOST_AUTO_TEST_CASE ), function templates (with BOOST_AUTO_TEST_CASE_TEMPLATE ) and member functions of the Fixture class (with BOOST_FIXTURE_TEST_CASE ).

+1
source

If you need fine-grained control over what is checked and in what order. For example, the command line argument is used.

+1
source

In my case, due to the way I wanted the testing to be done, manual registration was easier.

This is due to the fact that I had a small number of tests that were applied to a large number of classes, each of which implemented the same interface. These were file format handlers that supported many different file formats, and I wanted to run the same set of tests for each (for example, open a file in each format and try to read some data.)

Initially, I used automatic registration, and I had to duplicate test cases for each supported file format. I actually did this with #include and some precompiler tricks, but nonetheless it was hard to maintain.

Instead, I switched to manual registration, as this allows me to create one set of tests, and these tests are added to the tree dozens of times, each copy working with a different class (to check each file format.) The code is much cleaner, and now most of the lines #ifdef disappeared, which is nice.

The answer to your question is similar to how to solve the problem with C ++ code during metaprogramming or not. C ++ metaprogramming may be a bit like automatic copy and paste, so you can type less code, write a more general algorithm, and run the compiler instead. Manual registration with Boost.Test is similar, allowing you to specify your test list using an algorithm (code), rather than listing each separately.

Of course, if most of your tests are unique, and you do not use the same test several times with different parameters, you probably will not see any benefit from switching to manual registration.

+1
source

http://www.boost.org/doc/libs/1_50_0/libs/test/doc/html/utf/user-guide/test-organization/manual-nullary-test-case.html

You can use class member functions with boost::bind , you can bind arguments to functions, etc.

If you use only tests based on using only functions, an automatic registration tool. It is very easy to switch to automatic registration. And you don’t need to worry about forgotten test anymore

http://www.boost.org/doc/libs/1_50_0/libs/test/doc/html/utf/usage-recommendations/generic.html

0
source

All Articles