[CXX-2470] test_util for matching exceptions should produce clearer explanation Created: 17/Mar/22  Updated: 28/Oct/23  Resolved: 22/Mar/22

Status: Closed
Project: C++ Driver
Component/s: Testing
Affects Version/s: None
Fix Version/s: 3.7.0

Type: Improvement Priority: Trivial - P5
Reporter: Jesse Williamson (Inactive) Assignee: Jesse Williamson (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Our current Catch2 helper for matching against an expected exception message produces this output on failure:

with expansion:
Failed to resolve doesnotexist.invalid: generic server error mongocxx::
exception contains message: "parse error"

While certainly useful, it is misleading: the exception does NOT contain the message "parse error". Instead, that is the message it was /expected/ to contain:

std::string describe() const override

{ return std::string("mongocxx::exception contains message: \"") + expected_msg + "\""; }

If the reader of the test message trusts the explanation, this can cause some real head-scratching.

This should be corrected so that the intent and output match, something like:

exception was expected to contain: "parse error"



 Comments   
Comment by Jesse Williamson (Inactive) [ 21/Mar/22 ]

https://github.com/mongodb/mongo-cxx-driver/pull/850

Generated at Wed Feb 07 22:06:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.