Setup Google Test for C++ in Visual Studio

Disclaimer: This blog quotes substantially from this post:
http://stackoverflow.com/questions/531941/how-to-setup-google-c-testing-framework-gtest-on-visual-studio-2005
I only did compilation work and added a few lines  
1. Download and build gtest
1.       Download
2.       Unzip to somewhere, say C:gtest
3.       Open C:gtestmsvcgtest.sln in Visual Studio
4.       Right click project -> properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> <Edit...>, add the following: _VARIADIC_MAX=10. Caution no space allowed here. Gtest use template with as many as 10 arguments.
5.       Build solution. This is to generate the gtestd.lib
  2. Configure your project to include gtest 
1.       Configuration Properties > C/C++ > General > Additional Include Directories: Add C:gtestinclude
2.       Configuration Properties > Linker > General > Additional Library Directories: Add
C:gtestmsvcgtestDebug
3.       Configuration Properties > Linker > Input > Additional Dependencies: Add gtestd.lib
4.       Right click project -> properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> <Edit...>, add the following: _VARIADIC_MAX=10. Caution no space allowed here. Gtest use template with as many as 10 arguments.

4.       Configuration Properties > C/C++ > Code Generation > Runtime Library: If your code links to a runtime DLL, choose Multi-threaded Debug DLL (/MDd). If not, choose Multi-threaded Debug (/MTd).

  3. Test gtest (pun intended)
1.       Add new source file testtest.cpp
2.       Paste:
#include "gtest/gtest.h" #include "yourProgramHeaderIfAny.h"
TEST(sample_test_case, sample_test)
{
    EXPECT_EQ(12);
}
 
int main(int argc, char** argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
    system("pause"); 
}
3.       Make sure you don’t have other global scope main function, of course.
4.      Run. You should see colorful messages printed.
Written on February 18, 2014