Merge pull request #3008 from hyukmyeong:update_tutorial

PiperOrigin-RevId: 340286884
This commit is contained in:
Andy Getz 2020-11-02 22:26:39 -05:00
commit fb98f7447e
3 changed files with 80 additions and 62 deletions

View File

@ -51,7 +51,7 @@ More detailed documentation for googletest is in its interior
## Platforms ## Platforms
Google test has been used on a variety of platforms: GoogleTest has been used on a variety of platforms:
* Linux * Linux
* Mac OS X * Mac OS X
@ -94,11 +94,11 @@ result output. If your test runner understands TAP, you may find it useful.
runs tests from your binary in parallel to provide significant speed-up. runs tests from your binary in parallel to provide significant speed-up.
[GoogleTest Adapter](https://marketplace.visualstudio.com/items?itemName=DavidSchuldenfrei.gtest-adapter) [GoogleTest Adapter](https://marketplace.visualstudio.com/items?itemName=DavidSchuldenfrei.gtest-adapter)
is a VS Code extension allowing to view Google Tests in a tree view, and is a VS Code extension allowing to view GoogleTest in a tree view, and run/debug
run/debug your tests. your tests.
[C++ TestMate](https://github.com/matepek/vscode-catch2-test-adapter) is a VS [C++ TestMate](https://github.com/matepek/vscode-catch2-test-adapter) is a VS
Code extension allowing to view Google Tests in a tree view, and run/debug your Code extension allowing to view GoogleTest in a tree view, and run/debug your
tests. tests.
[Cornichon](https://pypi.org/project/cornichon/) is a small Gherkin DSL parser [Cornichon](https://pypi.org/project/cornichon/) is a small Gherkin DSL parser
@ -106,9 +106,9 @@ that generates stub code for Google Test.
## Requirements ## Requirements
Google Test is designed to have fairly minimal requirements to build and use GoogleTest is designed to have fairly minimal requirements to build and use with
with your projects, but there are some. If you notice any problems on your your projects, but there are some. If you notice any problems on your platform,
platform, please file an issue on the please file an issue on the
[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues). [GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues).
Patches for fixing them are welcome! Patches for fixing them are welcome!
@ -119,7 +119,7 @@ These are the base requirements to build and use Google Test from a source
package: package:
* [Bazel](https://bazel.build/) or [CMake](https://cmake.org/). NOTE: Bazel is * [Bazel](https://bazel.build/) or [CMake](https://cmake.org/). NOTE: Bazel is
the build system that googletest is using internally and tests against. the build system that GoogleTest is using internally and tests against.
CMake is community-supported. CMake is community-supported.
* A C++11-standard-compliant compiler * A C++11-standard-compliant compiler

View File

@ -35,8 +35,8 @@ Details and examples can be found here:
* [gMock Cookbook](docs/cook_book.md) * [gMock Cookbook](docs/cook_book.md)
* [gMock Cheat Sheet](docs/cheat_sheet.md) * [gMock Cheat Sheet](docs/cheat_sheet.md)
Please note that code under scripts/generator/ is from the [cppclean Please note that code under scripts/generator/ is from the
project](http://code.google.com/p/cppclean/) and under the Apache [cppclean project](http://code.google.com/p/cppclean/) and under the Apache
License, which is different from GoogleMock's license. License, which is different from GoogleMock's license.
GoogleMock is a part of GoogleMock is a part of

View File

@ -22,19 +22,31 @@ another project.
#### Standalone CMake Project #### Standalone CMake Project
When building GoogleTest as a standalone project, the typical workflow starts When building GoogleTest as a standalone project, the typical workflow starts
with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test's samples, you should replace the last command
with with
cmake -Dgtest_build_samples=ON ${GTEST_DIR} ```
git clone https://github.com/google/googletest.git -b release-1.10.0
cd googletest # Main directory of the cloned repository.
mkdir build # Create a directory to hold the build output.
cd build
cmake .. # Generate native build scripts for GoogleTest.
```
The above command also includes GoogleMock by default. And so, if you want to
build only GoogleTest, you should replace the last command with
```
cmake .. -DBUILD_GMOCK=OFF
```
If you are on a \*nix system, you should now see a Makefile in the current If you are on a \*nix system, you should now see a Makefile in the current
directory. Just type 'make' to build gtest. directory. Just type `make` to build GoogleTest. And then you can simply install
GoogleTest if you are a system administrator.
```
make
sudo make install # Install in /usr/local/ by default
```
If you use Windows and have Visual Studio installed, a `gtest.sln` file and If you use Windows and have Visual Studio installed, a `gtest.sln` file and
several `.vcproj` files will be created. You can then build them using Visual several `.vcproj` files will be created. You can then build them using Visual
@ -44,13 +56,19 @@ On Mac OS X with Xcode installed, a `.xcodeproj` file will be generated.
#### Incorporating Into An Existing CMake Project #### Incorporating Into An Existing CMake Project
If you want to use gtest in a project which already uses CMake, then a more If you want to use GoogleTest in a project which already uses CMake, the easiest
robust and flexible approach is to build gtest as part of that project directly. way is to get installed libraries and headers.
This is done by making the GoogleTest source code available to the main build
and adding it using CMake's `add_subdirectory()` command. This has the * Import GoogleTest by using `find_package` (or `pkg_check_modules`). For
significant advantage that the same compiler and linker settings are used example, if `find_package(GTest CONFIG REQUIRED)` is succeed, you can use
between gtest and the rest of your project, so issues associated with using the libraries as `GTest::gtest`, `GTest::gmock`.
incompatible libraries (eg debug/release), etc. are avoided. This is
And a more robust and flexible approach is to build GoogleTest as part of that
project directly. This is done by making the GoogleTest source code available to
the main build and adding it using CMake's `add_subdirectory()` command. This
has the significant advantage that the same compiler and linker settings are
used between GoogleTest and the rest of your project, so issues associated with
using incompatible libraries (eg debug/release), etc. are avoided. This is
particularly useful on Windows. Making GoogleTest's source code available to the particularly useful on Windows. Making GoogleTest's source code available to the
main build can be done a few different ways: main build can be done a few different ways: