2

I use VS 2010.

I need to run .exe that consists of BOOST_AUTO_TEST_SUITEs to test my library under debugger because I get memory access violation and memory leaks. I have no main function, just exe (well and the .cpp files).

How to run this exe under debugger?

UPDATE

If you have a solution with multiple projects in it, and you need to run 1 project that contains unit tests, for instance, under debugger, you need :

  1. right click on this project in Solution explorer
  2. click "Set as StartUp project"
  3. put some break points

Personaly I did not know that I needed to set up my project as startup.

Uylenburgh
  • 1,277
  • 4
  • 20
  • 46

2 Answers2

1

UPDATE

If you have a solution with multiple projects in it, and you need to run 1 project that contains unit tests, for instance, under debugger, you need :

  1. right click on this project in Solution explorer
  2. click "Set as StartUp project"
  3. put some break points

Personaly I did not know that I needed to set up my project as startup.

Uylenburgh
  • 1,277
  • 4
  • 20
  • 46
0

There are a number of things you can attempt to debug your test suite, and this is the order I'd suggest you approach this:

  • Set the BOOST_TEST_CATCH_SYSTEM_ERRORS environment variable to get a better stack trace for the failure.

  • Set breakpoints at the start and end brace of (all) the test(s), as it is far more likely that your issue has something to do with the tests and not the framework and tests' setup.

  • Open the boost/test/impl/unit_test_main.ipp include file in Visual Studio and set a breakpoint in the unit_test_main method. You will be stepping through the test execution monitor, but this rarely gives more insight than simply looking at the tests themselves.

  • This is rarely required but you can also explicitly start at the very first main with Debug + Windows + Breakpoints + New, Function. There are four main methods that can be invoked on Windows before the CRT starts: mainCRTStartup, wmainCRTStartup, WinMainCRTStartup, wWinMainCRTStartup.

  • For memory leaks, make sure you use the --detect-memory-leak switch with order allocation ids:

    The Execution Monitor provides a limited ability to detect memory leaks
    during program execution, and to break program execution on specific
    memory allocation order number (1 - first allocation of memory in program,
    2 - second and so on).

Further, check how to run individual tests by name, it generally makes debugging easier if you can isolate just the faulty subset of the tests.

mockinterface
  • 14,452
  • 5
  • 28
  • 49