-1

I've created unit test project for my C++ application in Visual Studio 2013. Unfortunately, it does not correctly handles exceptions during test: If i run test that just does following:

throw std::runtime_exception("hello!");

I see Windows "application has stopped working" box telling me that vstest.executionengine.exe has crashed. Meanwhile, Test Explorer in visual studio shows that this test has passed without errors.

Visual studio itself reports that "active test" was aborted, and error is unexpected. Reffers to https://msdn.microsoft.com/en-us/library/bb787181(VS.85).aspx but there is absolutely no useful information on that page about my problem.

How to properly terminate test execution in C++?

Croll
  • 3,631
  • 6
  • 30
  • 63
  • http://stackoverflow.com/questions/396369/how-do-i-disable-the-debug-close-application-dialog-on-windows-vista does not help, it still says that test has passed in 1 sec. Debugging test code after exception is thrown shows that it attempts to read memory at 08h before crash. – Croll Jul 18 '15 at 19:40

1 Answers1

0

Solution

  • Ensure that all your tests can run at one time, because that's how unit tests work in VS2013 (Run All i mean)
  • Ensure that you have no assert(..) calls, use Assert class provided by header CppUnitTestAssert.h
  • Try removing I/O from your test code, for example, try using Logger class provided by header CppUnitTestLogger.h instead of your own implementation
  • Use command TESTS > Debug > Debug all tests to run all tests in debug mode, you will definetely find reason of your crashes.

More information

Reason of crashes

I think it is how assertion worked in my code, maybe it's abort(). This caused something unexpected in hosting process.

Croll
  • 3,631
  • 6
  • 30
  • 63