Is there an option to show only failed tests? I had to switch to use Guitar to achieve this, but I miss command line tool.
If you need to disable all tests in a test suite, you can either add DISABLED_ to the front of the name of each test, or alternatively add it to the front of the test suite name.
gtest-parallel is a script that executes Google Test binaries in parallel, providing good speedup for single-threaded tests (on multi-core machines) and tests that do not run at 100% CPU (on single- or multi-core machines).
Since these precondition checks cause the processes to die, we call such tests death tests. More generally, any test that checks that a program terminates in an expected fashion is also a death test.
I ran into the same issue - as I'm sure many other people have. So I created this:
https://gist.github.com/elliotchance/8215283
Should be pretty much paste and play.
There are two ways to achieve this.
first one is to write your own event listener:
https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#defining-event-listeners
Another way is to filter the input the googletest event listener receives.
For this approache you remove the current event listener and exchange it with your own
testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners();
testing::TestEventListener* listener = listeners.Release(listeners.default_result_printer());
listeners.Append(new FailurePrinter(listener));
where FailurePrinter is your own event listener class.
This class should look like this
class FailurePrinter : public ::testing::TestEventListener {
public:
FailurePrinter(TestEventListener* listener) : TestEventListener() {_listener = listener;}
virtual void OnTestProgramStart(const UnitTest& unit_test);
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
virtual void OnTestCaseStart(const TestCase& test_case);
virtual void OnTestStart(const TestInfo& test_info);
virtual void OnTestPartResult(const TestPartResult& result);
virtual void OnTestEnd(const TestInfo& test_info);
virtual void OnTestCaseEnd(const TestCase& test_case);
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestProgramEnd(const UnitTest& unit_test);
protected:
testing::TestEventListener* _listener;
};
Now you have to implement all the methods.
If you like the way googles event listener prints something, just delegate the call to the _listener.
Or you can modify the result. For example:
void FailurePrinter::OnTestPartResult(const TestPartResult& test_part_result)
{
if (test_part_result.failed())
{
_listener->OnTestPartResult(test_part_result);
printf("\n");
}
}
will only print Testfailures.
There is a built-in solution for this now:
your_test_binary --gtest_brief=1
See also the documentation. There is also the GTEST_BRIEF environment variable to configure this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With