Tests skipping at runtime

1,587 views
Skip to first unread message

in...@dasir.cz

unread,
Apr 4, 2012, 5:04:33 AM4/4/12
to Google C++ Testing Framework
Hi!

Is it possible to skip a test case programmatically at runtime like in
other frameworks (e.g. http://groups.google.com/group/testng-users/browse_thread/thread/e22a9daab61b50eb)?

Thanks.

David

Greg Miller

unread,
Apr 4, 2012, 10:29:18 AM4/4/12
to in...@dasir.cz, Google C++ Testing Framework
Not really at runtime, but have you seen http://code.google.com/p/googletest/wiki/AdvancedGuide#Temporarily_Disabling_Tests that shows how to disable tests?

in...@dasir.cz

unread,
Apr 4, 2012, 10:37:53 AM4/4/12
to Google C++ Testing Framework
This temporary disabling does not suit my needs. I have a library
communicating with some PCI and USB devices. They might and might not
be present on the computer. What I need is that I plug some of the
devices and run tests for the whole library (not just HW devices
interfaces) without any hand modifications (disabling or filtering).
Tests for non-present devices should be skipped.

On Apr 4, 4:29 pm, Greg Miller <j...@google.com> wrote:
> Not really at runtime, but have you seenhttp://code.google.com/p/googletest/wiki/AdvancedGuide#Temporarily_Di...

Greg Miller

unread,
Apr 4, 2012, 10:48:55 AM4/4/12
to in...@dasir.cz, Google C++ Testing Framework
I see. Have you seen the doc on filtering tests? That might work. For example, you might run:

./foo_test --gtest_filter=PCI.*
or
./foo_test --gtest_filter=PCI.*:USB:*

To make this automatic, you could probably wrap this in a small script that figures out which tests you want to run.

If you want to do this programmatically in the test itself, you could also set this flag value in your main() function before calling RUN_ALL_TESTS().

HTH,
Greg
Reply all
Reply to author
Forward
0 new messages