On Thu, May 1, 2008 at 3:59 PM, Ovanes Markarian <om_boost@keywallet.com> wrote:
Please see my answers below.

On Thu, May 1, 2008 at 9:33 PM, Robert Dailey <rcdailey@gmail.com> wrote:
Hey guys,

I'm currently in the process of researching Boost.Test. I've never used it before, and reading through the documentation for it and the various examples, I have a few questions I can't find the answers to. I'll post them below:
  1. init_unit_test_suite is used fairly exclusively through the examples. The most I can gather is that this function begins the unit test. In other words, it calls other smaller functions which perform tests. How is this function evoked?
This function is invoked by the unit test framework internally.
 
  1. What is the difference in using init_unit_test_suite versus using #define BOOST_TEST_MAIN?
 Using init_unit_test_suite you have to manually register all your test cases to be excuted. Using BOOST_TEST_MAIN and BOOST_TEST_CASE (or whatever was the name of the macro) the framework will handle it for you. You just write test cases and are no longer required to care about main() and test case registration.

  1. When creating a unit test as a console application in Visual Studio, I would of course be required to implement the normal int main() function, but what would I have to do inside of main() or WinMain() to begin the unit test? I never found any examples that showed this.
As already stated these function are implemented by the test framework which links with your code and compiler finds them. The main drawback using init_unit_test_suite is when you are not allowed to use a static version of the boost test lib, so that DLL links to your code. In this case main and so on are required to be implemented by you, where in case of BOOST_TEST_MAIN it is automatically generated by the macro.

I initially used init_unit_test_suite to be able to create test hierarchies  but after switching to the dynamic boost lib (due to project requirements) I was forced to reimplement the init_unit_test_suite. It was not difficult, but I had to find how to do it, which was not easy.

This is the code I used:

<snip>



If I think of more questions I'll be sure to post follow ups. Help is greatly appreciated. Thanks in advance!

Hope that helps,
Ovanes

@Ovanes:

Thanks for your help. Right now I'm building the entire boost library as shared libraries. Is there a way I can specifically make bjam build the Boost.Test framework as a static library? If it saves me a lot of trouble I'd rather it be a static library. I'm not very good with bjam so if someone could tell me how to make Boost.Test build statically I'd appreciate it.