1

I am testing my c++11 static lib in vs 2013 environment. I followed this nice tutorial and testing + code coverage are working fine.

Now I need step-by-step : I added breakpoints and executed the "Debug Selected Test" command and I get the following message : vstest.executionengine.exe has triggered a breakpoint and the callstack brings me at CppUnitTest.h:465 : (static_cast<ThisClass *>(this)->*method2)();, eg at the root call of the method I want to break into. No way to see the code inside this call.

My question : how to break into my code during debugging Ms cpp unit test ?

norisknofun
  • 859
  • 1
  • 8
  • 24
  • Is your breakpoint at the beginning of `method2()`? Are you sure that `this` can be validly cast into `ThisClass*` ? – Mike C Mar 16 '15 at 20:05
  • Yes, the breakpoint is in the middle of the tested method. – norisknofun Mar 16 '15 at 20:15
  • Take a good look at the Call Stack window, be sure to scroll up if necessary. Double-click the frame at the very top. The debugger will display source code for the last stack frame it can find source for. Not a problem for CppUnitTest.h, easy to find, some odds that it cannot find yours. – Hans Passant Mar 16 '15 at 21:37
  • Top of callstack is the invocation of my test method, defined via the `TEST_METHOD` macro. Nothing more on stack. How to help the engine to find my code ? – norisknofun Mar 16 '15 at 22:35

1 Answers1

0

I found the problem. Some breakpoints were activated inside the static lib used by the test dll. It seems breakpoints inside static lib generates something wrong for the test framework.

To reproduce :

  • create c++ static lib project with a simple function, int foo(){ return 0;}
  • create a test-dll project
  • add a test function which calls foo
  • set a breakpoint in foo
  • execute "run selected test" : it will work
  • execute "debug selected test" : it will block just before calling the test-method test-generated class.

I am still interested in explaining this non-intuitive behaviour.

norisknofun
  • 859
  • 1
  • 8
  • 24