By default successful runs of Catch test produce output listing how many tests were run. I'm looking to use Catch in an environment where one of the ways the Catch tests will be run is by an automated system that checks the output of whatever executable it runs and flags and differences from previous runs as errors. In this environment adding a test will cause the default behavior of Catch to produce different output and so would be flagged as an error, requiring someone to manually look at the output.
I'm interested in the best way to stabilize the output of running Catch tests so that adding tests will not be flagged as an error by the automated system (but that any failures will be).
As I understand it I can write my own main and substitute the output streams so that I could do something like this:
#define CATCH_CONFIG_RUNNER
#define CATCH_CONFIG_NOSTDOUT
#include "catch.hpp"
#include <sstream>
std::ostringstream sout;
std::ostringstream serr;
namespace Catch {
std::ostream &cout() { return sout; }
std::ostream &cerr() { return serr; }
}
int main(int argc, char *argv[]) {
int result = Catch::Session().run(argc, argv);
if (result) {
std::cout << sout.rdbuf();
std::cerr << serr.rdbuf();
}
return result;
}
I'm wondering if Catch supports any better way to handle this situation.