1

I have a library inside which there are some testing programs written using Boost.Test. The test files don't have #define BOOST_TEST_DYN_LINK or #include <boost/test/included/unit_test.hpp>. They only have #include <boost/test/unit_test.hpp>. So the main() function isn't there implicitly.

Now I have to debug some library functions which have been used in the test cases. Given that I cannot add or change anything in the test programs, how can I invoke the test programs under a debugger ?

ayandas
  • 2,070
  • 1
  • 13
  • 26
  • If you can't add anything, then how would you add your own `main()`? You say "programs" which would imply there's an executable produced. So just run them in the debugger like any other executable (you didn't specify platform or toolkit, so I can't give you any more detail on that). | At this point, the question is rather confusing, please elaborate more. – Dan Mašek May 26 '16 at 15:56
  • Sorry, by programs I meant files (CPP files) and I am not allowed to change those CPP files in anyway. There is no executable. But I can create new files and compile them to generate executable and that is exactly my question, how can I do that ? Btw, I'm using QtCreator as IDE, g++4.8 on ubuntu. – ayandas May 26 '16 at 19:23
  • The framework seems to be used [as static library](http://www.boost.org/doc/libs/1_61_0/libs/test/doc/html/boost_test/usage_variants.html#boost_test.usage_variants.static_lib) - so just follow those instructions to make the test runner. – Dan Mašek May 26 '16 at 19:39

1 Answers1

0

Create a test runner (e.g. main_test.cpp) and link your library against that.

# main_test.cpp
// --- Boost Includes ---
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

Invoking the resulting executable should run your tests. You can then debug individual tests by invoking the runner with ./myrunner --run_test='some_testsuite'/../'some_testname'.

ToniBig
  • 836
  • 6
  • 21