Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.12 KB

TestingExceptions.md

File metadata and controls

31 lines (20 loc) · 1.12 KB

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 */ });

snippet source | anchor

Handling multiple exceptions in one test

See ExceptionCollector.


Back to User Guide