Testing Exceptions
August 26, 2021 ยท View on GitHub
Testing Exceptions
Contents
Testing exception messages
Testing exceptions with Approval Tests is very easy. Simply pass in a call to the function (usually wrapped in a lambda). Approval tests will execute the code, catch the exception, and verify the exception's message, i.e. exception.what().
The exception thrown must inherit std::exception.
ApprovalTests::Approvals::verifyExceptionMessage([]() { /* your code goes here */ });
Handling multiple exceptions in one test
See ExceptionCollector.