Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: testing/gmock/README

Issue 140003: Upgrade gtest to r267 and gmock to r173. (Closed)
Patch Set: final fileset. Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/gmock/Makefile.am ('k') | testing/gmock/configure.ac » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Google C++ Mocking Framework 1 Google C++ Mocking Framework
2 ============================ 2 ============================
3 http://code.google.com/p/googlemock/ 3 http://code.google.com/p/googlemock/
4 4
5 Overview 5 Overview
6 -------- 6 --------
7 Google's framework for writing and using C++ mock classes on Linux, 7 Google's framework for writing and using C++ mock classes on Linux,
8 Mac OS X, and Windows. Inspired by jMock, EasyMock, and Hamcrest, and 8 Mac OS X, and Windows. Inspired by jMock, EasyMock, and Hamcrest, and
9 designed with C++'s specifics in mind, it can help you derive better 9 designed with C++'s specifics in mind, it can help you derive better
10 designs of your system and write better tests. 10 designs of your system and write better tests.
(...skipping 22 matching lines...) Expand all
33 project (http://code.google.com/p/cppclean/) and under the Apache 33 project (http://code.google.com/p/cppclean/) and under the Apache
34 License, which is different from Google Mock's license. 34 License, which is different from Google Mock's license.
35 35
36 Requirements 36 Requirements
37 ------------ 37 ------------
38 Google Mock is not a testing framework itself. Instead, it needs a 38 Google Mock is not a testing framework itself. Instead, it needs a
39 testing framework for writing tests. It works with Google Test 39 testing framework for writing tests. It works with Google Test
40 (http://code.google.com/p/googletest/) out of the box. You can use 40 (http://code.google.com/p/googletest/) out of the box. You can use
41 either the copy of Google Test that comes with Google Mock, or a 41 either the copy of Google Test that comes with Google Mock, or a
42 compatible version you already have. This version of Google Mock 42 compatible version you already have. This version of Google Mock
43 requires Google Test 1.3.0. 43 requires Google Test 1.4.0.
44 44
45 You can also easily configure Google Mock to work with another testing 45 You can also easily configure Google Mock to work with another testing
46 framework of your choice; although it will still need Google Test as 46 framework of your choice; although it will still need Google Test as
47 an internal dependency. Please read 47 an internal dependency. Please read
48 http://code.google.com/p/googlemock/wiki/ForDummies#Using_Google_Mock_with_Any_T esting_Framework 48 http://code.google.com/p/googlemock/wiki/ForDummies#Using_Google_Mock_with_Any_T esting_Framework
49 for how to do it. 49 for how to do it.
50 50
51 Google Mock depends on advanced C++ features and thus requires a more 51 Google Mock depends on advanced C++ features and thus requires a more
52 modern compiler. The following are needed to use Google Mock: 52 modern compiler. The following are needed to use Google Mock:
53 53
54 ### Linux Requirements ### 54 ### Linux Requirements ###
55 These are the base requirements to build and use Google Mock from a source 55 These are the base requirements to build and use Google Mock from a source
56 package (as described below): 56 package (as described below):
57 * GNU-compatible Make or "gmake" 57 * GNU-compatible Make or "gmake"
58 * POSIX-standard shell 58 * POSIX-standard shell
59 * POSIX(-2) Regular Expressions (regex.h) 59 * POSIX(-2) Regular Expressions (regex.h)
60 * gcc 4.0 or newer, or gcc 3.4 or newer with the tr1 tuple library 60 * gcc 3.4 or newer.
61 (from Boost or other vendors).
62 61
63 Furthermore, if you are building Google Mock from a VCS Checkout (also 62 Furthermore, if you are building Google Mock from a VCS Checkout (also
64 described below), there are further requirements: 63 described below), there are further requirements:
65 * Automake version 1.9 or newer 64 * Automake version 1.9 or newer
66 * Autoconf version 2.59 or newer 65 * Autoconf version 2.59 or newer
67 * Libtool / Libtoolize 66 * Libtool / Libtoolize
68 * Python version 2.3 or newer 67 * Python version 2.3 or newer
69 68
70 ### Windows Requirements ### 69 ### Windows Requirements ###
71 * Microsoft Visual C++ 8.0 SP1 or newer 70 * Microsoft Visual C++ 8.0 SP1 or newer
72 * An implementation of the tr1 tuple C++ library (You can get it for
73 free from http://www.boost.org/. We have verified that version
74 1.36.0 works. One caveat is this implementation exposes a bug in
75 Visual C++'s <type_info> header when exceptions are disabled.
76 Therefore your project must enable exceptions for this
77 configuration to work.)
78 71
79 ### Mac OS X Requirements ### 72 ### Mac OS X Requirements ###
80 * Mac OS X 10.4 Tiger or newer 73 * Mac OS X 10.4 Tiger or newer
81 * Developer Tools Installed 74 * Developer Tools Installed
82 75
83 Getting the Source 76 Getting the Source
84 ------------------ 77 ------------------
85 There are two primary ways of getting Google Mock's source code: you can 78 There are two primary ways of getting Google Mock's source code: you can
86 download a source release in your preferred archive format, or directly check 79 download a source release in your preferred archive format, or directly check
87 out the source from a Version Control System (VCS, we use Google Code's 80 out the source from a Version Control System (VCS, we use Google Code's
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 [1] Google Mock Downloads: http://code.google.com/p/googlemock/downloads/list 127 [1] Google Mock Downloads: http://code.google.com/p/googlemock/downloads/list
135 128
136 Once downloaded expand the archive using whichever tools you prefer for that 129 Once downloaded expand the archive using whichever tools you prefer for that
137 type. This will always result in a new directory with the name "gmock-X.Y.Z" 130 type. This will always result in a new directory with the name "gmock-X.Y.Z"
138 which contains all of the source code. Here are some examples in Linux: 131 which contains all of the source code. Here are some examples in Linux:
139 132
140 tar -xvzf gmock-X.Y.Z.tar.gz 133 tar -xvzf gmock-X.Y.Z.tar.gz
141 tar -xvjf gmock-X.Y.Z.tar.bz2 134 tar -xvjf gmock-X.Y.Z.tar.bz2
142 unzip gmock-X.Y.Z.zip 135 unzip gmock-X.Y.Z.zip
143 136
137 Choosing a TR1 Tuple Library
138 ----------------------------
139 Google Mock uses the C++ Technical Report 1 (TR1) tuple library
140 heavily. Unfortunately TR1 tuple is not yet widely available with all
141 compilers. The good news is that Google Test 1.4.0+ implements a
142 subset of TR1 tuple that's enough for Google Mock's need. Google Mock
143 will automatically use that implementation when the compiler doesn't
144 provide TR1 tuple.
145
146 Usually you don't need to care about which tuple library Google Test
147 and Google Mock use. However, if your project already uses TR1 tuple,
148 you need to tell Google Test and Google Mock to use the same TR1 tuple
149 library the rest of your project uses (this requirement is new in
150 Google Test 1.4.0 and Google Mock 1.2.0, so you may need to take care
151 of it when upgrading from an earlier version), or the two tuple
152 implementations will clash. To do that, add
153
154 -DGTEST_USE_OWN_TR1_TUPLE=0
155
156 to the compiler flags while compiling Google Test, Google Mock, and
157 your tests.
158
159 If you want to use Boost's TR1 tuple library with Google Mock, please
160 refer to the Boost website (http://www.boost.org/) for how to obtain
161 it and set it up.
162
144 Building the Source 163 Building the Source
145 ------------------- 164 -------------------
146 ### Linux and Mac OS X (without Xcode) ### 165 ### Linux and Mac OS X (without Xcode) ###
147 There are two primary options for building the source at this point: build it 166 There are two primary options for building the source at this point: build it
148 inside the source code tree, or in a separate directory. We recommend building 167 inside the source code tree, or in a separate directory. We recommend building
149 in a separate directory as that tends to produce both more consistent results 168 in a separate directory as that tends to produce both more consistent results
150 and be easier to clean up should anything go wrong, but both patterns are 169 and be easier to clean up should anything go wrong, but both patterns are
151 supported. The only hard restriction is that while the build directory can be 170 supported. The only hard restriction is that while the build directory can be
152 a subdirectory of the source directory, the opposite is not possible and will 171 a subdirectory of the source directory, the opposite is not possible and will
153 result in errors. Once you have selected where you wish to build Google Mock, 172 result in errors. Once you have selected where you wish to build Google Mock,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 248
230 # When using a built but not installed Google Mock: 249 # When using a built but not installed Google Mock:
231 g++ $(../../my_gmock_build/scripts/gmock-config ...) ... 250 g++ $(../../my_gmock_build/scripts/gmock-config ...) ...
232 251
233 Note that when building your project against Google Mock, you are building 252 Note that when building your project against Google Mock, you are building
234 against Google Test as well. There is no need to configure Google Test 253 against Google Test as well. There is no need to configure Google Test
235 separately. 254 separately.
236 255
237 ### Windows ### 256 ### Windows ###
238 The msvc/ directory contains VC++ 2005 projects for building Google 257 The msvc/ directory contains VC++ 2005 projects for building Google
239 Mock and selected tests. In order to build Google Mock you must have 258 Mock and selected tests.
240 an implementation of TR1 tuple. One library that provides such
241 implementation is Boost. If you choose to use Boost, download it from
242 www.boost.org and install it on your system. Note that Boost TR1 tuple
243 is a header-only library, so the installation only involves unpacking
244 it to a suitable location - you don't need to compile it or download a
245 pre-compiled Boost binary.
246
247 Since Boost is quite large, you may prefer to only install the files
248 actually needed by Google Mock. If so, you can download TR1 tuple
249 without other parts of Boost from
250 http://code.google.com/p/googlemock/downloads/list.
251
252 After that you have two options: either set up Boost globally or
253 modify the Google Mock project to point to your copy of Boost. The
254 former will let all your tests use the same Boost library while the
255 latter will allow each of your projects use its own copy. You can also
256 use a hybrid solution: your project settings will override the
257 system-wide one.
258
259 For example, if you unpacked boost v1.36.0 into C:\boost:
260 To set up Boost such that all projects can use it:
261 * Assuming you are using the Visual Studio 2005 IDE, select Tools |
262 Options | Projects And Solutions | VC++ Directories.
263 * In the "Show directories for" drop-down select Include Files. Add
264 C:\boost\boost_1_36_0\boost\tr1\tr1 and C:\boost\boost_1_36_0 to the
265 list of directories.
266
267 To configure your project to point to that version of Boost, replace
268 the value of the BoostDir user macro with C:\boost\boost_1_36_0 in the
269 msvc/gmock_config.vsprops file. You can use any text editor to edit
270 that file.
271 259
272 If you want to use a version of Google Test other then the one bundled with 260 If you want to use a version of Google Test other then the one bundled with
273 Google Mock, change the value of the GTestDir macro in gmock_config.vsprop 261 Google Mock, change the value of the GTestDir macro in gmock_config.vsprop
274 to point to the new location. 262 to point to the new location.
275 263
276 After configuring Boost, just open msvc/gmock.sln and build the library and 264 Open msvc/gmock.sln and build the library and tests. If you want to
277 tests. If you want to create your own project to use with Google Mock, you'll 265 create your own project to use with Google Mock, you'll have to
278 have to configure it to use the gmock_config propety sheet. For that: 266 configure it to use the gmock_config propety sheet. For that:
279 * Open the Property Manager window (View | Other Windows | Property Manager) 267 * Open the Property Manager window (View | Other Windows | Property Manager)
280 * Right-click on your project and select "Add Existing Property Sheet..." 268 * Right-click on your project and select "Add Existing Property Sheet..."
281 * Navigate to gmock_config.vsprops and select it. 269 * Navigate to gmock_config.vsprops and select it.
282 * In Project Properties | Configuration Properties | General | Additional 270 * In Project Properties | Configuration Properties | General | Additional
283 Include Directories, type <path to Google Mock>/include. 271 Include Directories, type <path to Google Mock>/include.
284 272
285 TODO(wan@google.com): update the .vsprops and .vcproj files such that the 273 TODO(wan@google.com): update the .vsprops and .vcproj files such that the
286 last step is unnecessary. 274 last step is unnecessary.
287 275
288 ### Using GNU Make ### 276 ### Using GNU Make ###
(...skipping 24 matching lines...) Expand all
313 301
314 cd ${SRCDIR} 302 cd ${SRCDIR}
315 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \ 303 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \
316 -c {GTEST_SRCDIR}/src/gtest-all.cc 304 -c {GTEST_SRCDIR}/src/gtest-all.cc
317 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \ 305 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \
318 -c src/gmock-all.cc 306 -c src/gmock-all.cc
319 ar -rv libgmock.a gtest-all.o gmock-all.o 307 ar -rv libgmock.a gtest-all.o gmock-all.o
320 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \ 308 g++ -I. -I./include -I${GTEST_SRCDIR} -I${GTEST_SRCDIR}/include \
321 path/to/your_test.cc libgmock.a -o your_test 309 path/to/your_test.cc libgmock.a -o your_test
322 310
323 On Windows, you'll also need to add the include path for the boost
324 headers to the compiler command line. See
325 http://www.boost.org/doc/libs/1_36_0/doc/html/boost_tr1/usage.html for
326 how to do it.
327
328 Regenerating Source Files 311 Regenerating Source Files
329 ------------------------- 312 -------------------------
330 Some of Google Mock's source files are generated from templates (not 313 Some of Google Mock's source files are generated from templates (not
331 in the C++ sense) using a script. A template file is named FOO.pump, 314 in the C++ sense) using a script. A template file is named FOO.pump,
332 where FOO is the name of the file it will generate. For example, the 315 where FOO is the name of the file it will generate. For example, the
333 file include/gmock/gmock-generated-actions.h.pump is used to generate 316 file include/gmock/gmock-generated-actions.h.pump is used to generate
334 gmock-generated-actions.h in the same directory. 317 gmock-generated-actions.h in the same directory.
335 318
336 Normally you don't need to worry about regenerating the source files, 319 Normally you don't need to worry about regenerating the source files,
337 unless you need to modify them (e.g. if you are working on a patch for 320 unless you need to modify them (e.g. if you are working on a patch for
338 Google Mock). In that case, you should modify the corresponding .pump 321 Google Mock). In that case, you should modify the corresponding .pump
339 files instead and run the 'pump' script (for Pump is Useful for Meta 322 files instead and run the 'pump' script (for Pump is Useful for Meta
340 Programming) to regenerate them. We are still working on releasing 323 Programming) to regenerate them. We are still working on releasing
341 the script and its documentation. If you need it now, please email 324 the script and its documentation. If you need it now, please email
342 googlemock@googlegroups.com such that we know to make it happen 325 googlemock@googlegroups.com such that we know to make it happen
343 sooner. 326 sooner.
344 327
345 Happy testing! 328 Happy testing!
OLDNEW
« no previous file with comments | « testing/gmock/Makefile.am ('k') | testing/gmock/configure.ac » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698