- Add a New Project to the solution
- Right-click on Solution - Add > New Project
- Select Win32 Console Application
- Give it a name
- Click Ok
- Click Finish on the Wizard that pops up
- Change the Project Properties
- Change Configuration at the top to All Configurations
- Under Configuration Properties > General > Use of MFC
- Change the selection to be Use MFC in a Shared DLL
- Under Configuration Properties > C/C++ > General > Additional Include Directories
- Add the path to the include folder for Google Mock
- Ex. - ..\..\CoreThirdParty\gmock-1.5.0\include
- (CoreThirdParty is a directory that houses Google Mock, Google Test, and other Third Party headers and libraries that our project depends on)
- Add the path to the include folder for Google Test
- Ex. - ..\..\CoreThirdParty\gtest-1.5.0\include
- Under Configuration Properties > Linker > General > Additional Library Directories
- Add the path to the Release folder for Google Mock
- Ex. ..\..\CoreThirdParty\gmock-1.5.0\msvc\Release
- Under Configuration Properties > Linker > Input > Additional Dependencies
- Add the libraries for Google Mock
- gmock.lib
- gmock_main.lib
- Under Configuration Properties > Build Events > Post-Build Event > Command Line
- Add the command to run the executable after the build is finished
- "$(TargetDir)$(TargetFileName)" --gtest_filter=*.* --gtest_shuffle --gtest_output=xml
- Add a HookUpTest to the .cpp file
- Remove all of the code in the .cpp file that was created with the project
- Add the following code to create a HookUp Test
#include <gmock/gmock.h> TEST(SimpleTest, HookUpTest) { ASSERT_TRUE(true); }
Build this project and hopefully the output will be:
1>Finished generating code
1>Embedding manifest...
1>Performing Post-Build Event...
1>Running main() from gmock_main.cc
1>[==========] Running 1 test from 1 test case.
1>[----------] Global test environment set-up.
1>[----------] 1 test from SimpleTest
1>[ RUN ] SimpleTest.HookUpTest
1>[ OK ] SimpleTest.HookUpTest(0 ms)
1>[----------] 1 test from SimpleTest(0 ms total)
1>[----------] Global test environment tear-down
1>[==========] 1 test from 1 test case ran. (0 ms total)
1>[ PASSED ] 1 test.
No comments:
Post a Comment