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?
Thanks
Ivo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
Thanks
Ivo
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.