-
Notifications
You must be signed in to change notification settings - Fork 46
Description
When I'm testing a binary that I'm writing, I like to test exit status, standard output, and standard error in all cases. However, sometimes I forget, leaving gaps in test coverage.
It would be nice if there was some way to enforce this.
One way which would be minimally invasive to the existing API would be to add a .must_assert() method, which returns an Assert object, configured so that when it is dropped it perform "default assertions" on those parts of the program output upon which another assertion has not been made.
The default assertions would be that the exit status is successful, standard output is empty, and standard error is empty.
Any assertion on exit status, i.e., success(), failure(), or code(), would suppress the default assertion of success, and
any assertion on standard output or standard error would suppress the default assertions that those output streams are empty.
Since it's not good to panic while panicking, these default assertions would only be performed if std::thread::panicking() returned false.