palaniappan-r's picture
Add markdown sources
d59bb1b verified

[developer docs] Errors thrown in C++ test files?

Subcategory: Best practices

Conversation

cdleary

I presume for errors in C++ test code (e.g. fixtures and similar) it's ok to throw more "bare" errors (vs the scheme used with the logger and explicitly enumerated exceptions) -- that is, it's ok to throw a derived class from std::runtime_error if something goes wrong in test fixture scaffolding?

If so I'll update the developer docs with a small note, but I wanted to check this seemed ok.

CC @maliberty

cdleary

(Or if non-exception-code is preferred in test code, that'd be fine too, just let me know what the preferred way to fatal-error-with-message would be.)

cdleary

(Or possibly we use logger with an error ID of 0 for a testing use cases like this?)

Apologies for the stream of conscious of possibilities. :-)

maliberty

What do you mean by "explicitly enumerated exceptions"? In general I'm ok with your initial statement.