Friday, July 10, 2009

Gtest Starters Help(Building and Writing Tests)

Summary: This article will help you configure google test for the first time in Visual Studio IDE. It will take you through the installation process to writing your first ATP's on gtest.


!!!Installation:
• After Downloading Gtest the next step is to build it. To do this is fairly easy just open \msvc\gtest.sln’ in Visual Studio and Build it just like any other project.
• After Building notice that a ‘Release’ folder will be created in ‘\msvc’. That’s it you are ready to write you first ATP’s.


!!!Making a Test Project(Note: These are the settings only for release mode):
• Place the gtest directory in the local folder(where there is bin directory) of your project so that it can be machine independent
• Make a win32 console application Project in VS2008 with language settings as C++
• Go into Solution Explorer > Right Click Top Node > Add > Existing Project and Add two projects :
o \msvc\gtest
o ‘\msvc\gtest_main
• Go into Project Menu > Properties > Configuration Settings > C/C++ > Code Generation and set
o Basic Run Time Checks to “Both (/RTC1, equiv. to /RTCsu) “
o Run Time Library to “Multi-threaded(/MT)”

• Go into Project Menu > Properties > Configuration Settings > C/C++ > Optimization and set optimization: Disabled (/Od)

• In your Visual Studio Project open: Project Menu > Properties > Configuration Settings > C/C++ > Additional Dependencies(All configuration in combo box)
o Add on a new line in double quotes ‘$(InputDir)\gtest-1.3.0\include’ folder.
o Now make a Separate Source file and in that write the test methods using TEST’ macro
o And in Projects main source file call the tests using RUN_ALL_TEST

Note: is the gtest Directory which should be placed at the local project location
For Additional Help: http://code.google.com/p/googletest/w/list

No comments:

Post a Comment