Dynamically disable EXPECT_* and ASSERT_*

204 views
Skip to first unread message

baptist...@smartmeup.org

unread,
Jun 4, 2018, 9:34:47 AM6/4/18
to Google C++ Testing Framework
Hi, 

Within my team at work, we use the GoogleTest framework to check if everything goes as expected for our C and C++ libraries. We would like to use those tests in order to evaluate the coverage of our code and to check if leaks occur during execution. 

However we have some cases where the amount of data tested is important. Being in a computer vision environment we often need to test huge algorithms on several images. With valgrind as a topping executer, it quickly become a very long task to handle. But using some Google Test framework utilities like:

::testing::Environment

We can easily filter out some data. The idea being having 2 steps: 
  • Checking tests validity (with EXPECT_* and ASSERT_*)
  • Checking leaks (without EXPECT_* and ASSERT_*)
Although it is possible to use a recompilation to do that (using a compilation definition we can redefine those macros), I think it is better in a Continuous Integration purpose to avoid having to recompile everything and a runtime option to disable those macros would help (at least in my case). 

I don't know if this is something that could be useful for other people or if an other solution already exist but I haven't found anything that could do what I want at runtime. 

Any thoughts on this really appreciated. 

Josh Kelley

unread,
Jun 5, 2018, 8:19:09 AM6/5/18
to baptist...@smartmeup.org, Google C++ Testing Framework
I'm having a little trouble understanding your request. If I understand correctly, you want to run the software under test, but the EXPECT_ and ASSERT_ steps may take a long time to run just by themselves, and the EXPECT_ and ASSERT_ steps don't have anything that you care about checking with Valgrind, so you want to disable those? That's a very specialized request, and I don't think Google Test supports it out of the box.

I assume you've seen the documentation on filtering and on disabling and enabling tests?

You could always replace EXPECT_ and ASSERT_ (or your predicates that EXPECT_ and ASSERT_ call) with wrapper functions that selectively either do the test or always pass.

-- 
Josh Kelley

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

baptist...@smartmeup.org

unread,
Jun 5, 2018, 8:38:23 AM6/5/18
to Google C++ Testing Framework
Yes it's special, it's like changing the behaviour of macros at a runtime level. But I don't want to recompile my base binaries. I saw I could filter, disable or enable my tests but the idea is not to disable them just filter out the `EXPECT_*` and `ASSERT_*` parts. So if I change the amount of data processed, it doesn't have any influence of my tests success. I don't if Google could support it, it certainly is a strange feature to be supported in a testing framework.
Reply all
Reply to author
Forward
0 new messages