[test] BOOST_TEST_MAIN,BOOST_AUTO_TEST_CASE and MFC

I use the Boost Test library extensively, and to save time, I always define BOOST_TEST_MAIN and add tests using BOOST_AUTO_TEST_CASE. This works fine for most projects, but now I need to test some MFC code. In order for MFC objects to work correctly, I need to make a call to AfxWinInit, but the only way I can see to do this is to define my own init_unit_test_suite function and add tests 'by hand', rather than using BOOST_AUTO_TEST_CASE. Does anyone know of a way I can avoid adding tests by hand? Does the Boost auto main stuff make a call to any init function I can override, so I can squeeze in an MFC init call? Thanks in advance.

Robert Caldecott <robert.caldecott <at> gmail.com> writes:
I need to make a call to AfxWinInit, but the only way I can see to do this is to define my own init_unit_test_suite function and add tests 'by hand', rather than using BOOST_AUTO_TEST_CASE.
Does anyone know of a way I can avoid adding tests by hand? Does the Boost auto main stuff make a call to any init function I can override, so I can squeeze in an MFC init call?
There are number of possibilities, from implementing your own main function with either static and shared library to something as trivial as defining global fixture. Try later first: struct WinInitSetup { WinInitSetup() { AfxWinInit(); } }; BOOST_TEST_GLOBAL_FIXTURE( WinInitSetup ); Gennadiy
participants (2)
-
Gennadiy Rozental
-
Robert Caldecott