How to use boost :: unit_test?

I am trying to learn how to test programs, so I tried Boost. I started reading it and here I met this line:

Now I can compile it and link to the unit test framework .
Where and how can I get the unit test structure? And what is this?
 I just don’t know what to eat with him. Can someone please provide some steps on how to use it or maybe point me to other tutorials that will explain even the simplest things like unit test and how to relate it to. Thanks

+5
source share
1 answer

Just a quick comment. The problem with this library is that it has at least three different ways to implement and run tests. Depending on what #definesyou add to your code, before you include the boost unit test header, it can automatically generate the main function for you (and then create a complete program that runs the tests you defined), or rely on external test ones runners.

Read these operating modes carefully to know what to do. Usually the easiest way is to do this:

  • Include the tests in the .cpp file.
  • Before including the unit test header file, define a preprocessor macro BOOST_TEST_MAIN(this will determine the main function that will run the tests).
  • DLL libboost-unit-test ( ).

, .

+2

All Articles