Assuming all your tests use fixtures, and all your output is <iostream>
-based, you could do the following:
using namespace std;
class SomeTest : public testing::Test {
protected:
virtual void setUp() {
storedStreambuf_ = cout.rdbuf();
cout.rdbuf(nullptr);
}
virtual void tearDown() {
cout.rdbuf(storedStreambuf_);
}
private:
streambuf* storedStreambuf_;
};
This will suppress all output via cout
during your test's run, it can be done the same way for cerr
and clog
.
In order to keep this DRY, you could write a common base class inheriting from testing::Test
, and make all your fixtures based on that.