testing::internal::CaptureStdout(); std::cout << "My test"; std::string output = testing::internal::GetCapturedStdout();