Search code examples
googletest

exiting on FATAL asserts in google test framework


Is there any option or method to exit from google test framework completely without executing any further tests when we have identified a FATAL assert which renders any further testing useless ?


Solution

  • There is no specific mechanism provided by the library to abort execution, but nothing prevents you from using a standard assertion to abort program execution.

    #include <cassert>
    
    TEST(TestSuite, TestCase)
    {
        assert(<fatal condition>);
        // ...
    }
    

    If the fatal condition is the result of some test setup that you can control, you might be interested in learning about Google Test's support for Death Tests.