I don't know the scope of google test, so there may be a better way to do this, but this should do:
//--------------------------------------------- // some_header.h extern int my_argc; extern char** my_argv; // eof //--------------------------------------------- //--------------------------------------------- // main.cpp int my_argc; char** my_argv; int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); my_argc = argc; my_argv = argv; return RUN_ALL_TESTS(); } // eof //--------------------------------------------- //--------------------------------------------- // test.cpp #include "some_header.h" TEST(SomeClass, myTest) { // Here you can access my_argc and my_argv } // eof //---------------------------------------------
Globals are not very good, but when all you have is a test environment that will not allow you to tunnel some data from main() for any testing functions that you have, they do the job.
sbi
source share