I'm wondering if there is a way to catch assert from within cppUnit?, i would like to catch those and continue with other test.
There problem her is that often when testing error case there is an assert in the called function to prevent such a ''mistake''. Then the test are stopped. In a batch environment were we need to run multiple test, this is a problem
Can we put an errorHandler
Thanks,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm wondering if there is a way to catch assert from within cppUnit?, i would like to catch those and continue with other test.
There problem her is that often when testing error case there is an assert in the called function to prevent such a ''mistake''. Then the test are stopped. In a batch environment were we need to run multiple test, this is a problem
Can we put an errorHandler
Thanks,
Hi,
In our unittests (running on Linux) we override the assert handler like this, to 'convert' an assert into an exception:
void __assert_fail (const char *assertion, const char *file, unsigned int line, const char *function) {
throw my_exceptions::Exception("assert_handler");
}
Note: This requires gcc version 4.1.2 or newer to work correctly.
Regards
Jannich