First, I can't imagine wanting to do this, except locally, to
make the tests run faster to get to some more exotic cases;
EXPECT_TRUE
et al. are only useful in the Google test
environment, and should only appear in unit tests, not in the
body of your code.
Locally, I'd use a separate macro (so that someone reading the
code knows immediatly that it is a conditional test), say
COND_EXPECT_TRUE
(for conditional EXPECT_TRUE), defined
something like:
#ifdef ALL_TESTS
#define COND_EXPECT_TRUE EXPECT_TRUE
#else
#define COND_EXPECT_TRUE dummyOutput
#endif
, where dummyOutput
is an unopened std::ofstream
somewhere.
(Or if you really want to be sure, you can define a nullstream
class, which outputs into thin air. But in this case, and
conversions in the output will still occur; in an unopened
std::ofstream
, the fact that it is in an error state inhibits
the conversions.)