I have a test method SomeTest in a test class defined, using the CPPUNIT_TEST and other macros (the simplest way how to do it). I would like to have a possibility to stop the tests when something very bad happens. Generating exception will not help because CPPUNIT catches this exception and tests continue. How to tell CPPUNIT not to catch exceptions when needed? Or how else to do it?
My code is throwing an exception during a test and cppunit catches the exception, ends that test and says that the test was ok. Is this expected behaviour? If so I too would like to tell cppunit to not catch exceptions.
I found the cause of my problem: my exception was being caught somewhere unexpected in my own code. There was no problem with CppUnit :-)
Going back to the original post in this thread: I haven't tried this but if, like me, you are using TextTestRunner, you can pop the Protector object (via the TestResults object) which catches the exceptions thrown by the tests. I think this would stop CppUnit catching exceptions. Also you can create and push your own custom protector (start from CppUnit::DefaultProtector) and do whatever you want when exceptions are thrown.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.