GTEST is skipping some tests without clear reason

813 views
Skip to first unread message

Armand Chrystel Moutchiho

unread,
Jun 20, 2016, 10:56:10 AM6/20/16
to Google C++ Testing Framework
Hello Together,

I have implemented  a serie of unit tests for a tool with different modules. Until now everything was working fine. I have many times added a new module to my cmakelists and the test defined for these modules ran well. Only this time I have introduced a new module implementing my connections to mysql using its c++ connector. Any test I define usinga class from that directory is not beeing runned by GTEST. But when I define in the same files a test with the test case name beeing the class of a previously existin module for which the test was already working, then that test is called by GTEST wirthout problem. 
Please as this problem makes no sense to me , I have no idea on how to debug it or why Gtest is not running the later tests. Even when I define a class locally in one of this file, it doesn't work. The funny thing is that , if I define a test with the same name as a test from another module that works fine, the compiler detect the collision and give out an error message.
So the file and its test are well loaded by the cmakelists and compiled.

Can Anyone give me some good advice on how to proceed!?

Best regards!

Armand Moutchiho

Samuel Benzaquen

unread,
Jun 20, 2016, 11:01:41 AM6/20/16
to Armand Chrystel Moutchiho, Google C++ Testing Framework
Are you sure the tests are linked into the final binary?
The linker might be throwing away the compilation unit if it thinks it is unused.
You could check with either:
 * --gtest_list_tests and check if they are there.
 * nm on the binary to see if the functions exist in it at all.

There are two ways to fix this issue:
 1. you can explicitly use each compilation unit from your main file. You just need to use a symbol from those CUs. That will force the linker to keep them.
 2. or you can tell the linker to keep them even if they are unused. how to do that depends on the toolchain you are using.

This one seems like a very detailed explanation:

 

Best regards!

Armand Moutchiho

--

---
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 googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages