All notes
Gtes

Intallation

Although CMake and GTest reference each other in their reference/manual, they two are not that much compatible. For GTest, the easiest way to deploy on Linux is by conventional make (the codes could be partlyfound in GTest README):

g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} -pthread -c ${GTEST_DIR}/src/gtest-all.cc
# Archive .o into .a file. Now we have this static lib!
ar -rv libgtest.a gtest-all.o

# Noted by wcf: you may also need gtest_main to spare your own main function.
g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} -pthread -c ${GTEST_DIR}/src/gtest_main.cc
ar -rv libgtest_main.a gtest_main.o

# -pthread as Google Test uses threads.
# Compile your test source file with
g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a -o your_test
Link gtest_main.a or gtest.a with your binary based on whether you want to use Google's main() function or your own.

Tips

Selectively run tests

gtestApp --gtest_list_tests

gtestApp --gtest_filter=POSITIVE_PATTERNS[-NEGATIVE_PATTERNS]
Example:
gtestApp --gtest_filter=
// TEST(Foo, Bar) is "Foo.bar"

// Don't print elapsed time for each test.
gtestApp --gtest_print_time=0

gtestApp --gtest_color=(yes|no|auto)

gtest FAQ

Pass commandline arguments

Stackoverflow.

/////////////////////////////
// some_header.h
extern int my_argc;
extern char** my_argv;

/////////////////////////////
// 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();
}

Colored Terminal Output

Set the GTEST_COLOR environment variable or set the --gtest_color command line flag to yes, no, or auto (the default) to enable colors, disable colors, or let Google Test decide.

When the value is auto, Google Test will use colors if and only if the output goes to a terminal and (on non-Windows platforms) the TERM environment variable is set to xterm or xterm-color.