This project provides the Google Test source libraries as an xPack dependency.
The project is hosted on GitHub as xpack-3rd-party/googletest-xpack.
This page is addressed to developers who plan to include this source library into their own projects.
For maintainer info, please see the README-MAINTAINER-XPACK file.
As a source library xPacks, the easiest way to add it to a project is via xpm, but it can also be used as any Git project, for example as a submodule.
A recent xpm, which is a portable Node.js command line application.
For details please follow the instructions in the install page.
This package is available from npmjs.com as
@xpack-3rd-party/googletest
from the npmjs.com
registry:
cd my-project
xpm init # Unless a package.json is already present
xpm install @xpack-3rd-party/googletest@latest
ls -l xpacks/xpack-3rd-party-googletest
If, for any reason, xpm is not available, the next recommended
solution is to link it as a Git submodule below an xpacks
folder.
cd my-project
git init # Unless already a Git project
mkdir -p xpacks
git submodule add https://github.com/xpack-3rd-party/googletest-xpack.git \
xpacks/xpack-3rd-party-googletest
There are three active branches:
master
, follows the original Armmaster
xpack
, with the latest stable version (default)xpack-develop
, with the current development version
All development is done in the xpack-develop
branch, and contributions via
Pull Requests should be directed to this branch. (Only contributions
related to the xPack integration are accepted, functional contributions
should be addressed to the upstream project.)
When new releases are published, the xpack-develop
branch is merged
into xpack
.
This package provides the full Google Test & Mock code, but when installed via xpm the content is filtered and only the googletest & googlemock folders are used.
In addition to the source files, the configuration files required to integrate it into CMake and meson projects, by building a static library.
The project is written in C++, and is quite large. It can be built on top of an Arm semihosting environment, but it takes about 400-500KB of code space.
The following folders should be used during the build:
googletest/include
googlemock/include
The header files can then be included in user projects with statements like:
#include "gtest/gtest.h"
#include "gmock/gmock.h"
googletest
googlemock
The source file to be added to user projects are:
googletest/src/gtest-all.cc
googlemock/src/gmock-all.cc
There are several proprocessor definitions used to configure the build.
For embedded platfroms, use:
-DGTEST_HAS_PTHREAD=0
-D_POSIX_C_SOURCE=200809L
This will disable treading support in GTest and enable POSIX support in newlib.
-std=c++17
or higher for C++ sources-std=c11
for C sources
testing
The project includes many classes; see the documentation for details.
To integrate the Google Test source library into a CMake application, add this folder to the build:
add_subdirectory("xpacks/xpack-3rd-party-googletest")`
The result is a static library that can be added as an application dependency with:
target_link_libraries(your-target PRIVATE
...
xpack-3rd-party::googletest
)
To integrate the Google Test source library into a meson application, add this folder to the build:
subdir('xpacks/xpack-3rd-party-googletest')
The result is a static library and a dependency object that can be added as an application dependency with:
exe = executable(
your-target,
c_args: xpack_3rd_party_googletest_dependency_c_args,
cpp_args: xpack_3rd_party_googletest_dependency_cpp_args,
dependencies: [
xpack-3rd-party-googletest_dependency,
],
link_with: [
xpack_3rd_party_googletest_static,
],
)
A simple example showing how to use the Google Test framework is presented below and is also available in tests-xpack/src/sample-test.cpp.
#include "gtest/gtest.h"
static int
compute_one (void)
{
return 1;
}
static const char*
compute_aaa (void)
{
return "aaa";
}
TEST(Suite, Case1) {
EXPECT_EQ(1, compute_one());
EXPECT_STREQ("aaa", compute_aaa());
}
int
main ([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
{
printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
- none
The project is fully tested via GitHub Actions on each push. The test platforms are GNU/Linux, macOS and Windows, the tests are compiled with GCC, clang and arm-none-eabi-gcc and run natively or via QEMU.
There are two set of tests, one that runs on every push, with a limited number of tests, and a set that is triggered manually, usually before releases, and runs all tests on all supported platforms.
The full set can be run manually with the following commands:
cd ~Work/googletest-xpack.git
xpm run install-all
xpm run test-all
Tho original documentation is available on-line:
The original content is released under the MIT License, with all rights reserved to Liviu Ionescu.
The Google content is provided under the terms of the BSD-3-Clause License.
The original README content follows.
GoogleTest now follows the
Abseil Live at Head philosophy.
We recommend using the latest commit in the main
branch in your projects.
Our documentation is now live on GitHub Pages at https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in the repository.
Release 1.11.0 is now available.
- We are planning to take a dependency on Abseil.
- More documentation improvements are planned.
This repository is a merger of the formerly separate GoogleTest and GoogleMock projects. These were so closely related that it makes sense to maintain and release them together.
See the GoogleTest User's Guide for documentation. We recommend starting with the GoogleTest Primer.
More information about building GoogleTest can be found at googletest/README.md.
- An xUnit test framework.
- Test discovery.
- A rich set of assertions.
- User-defined assertions.
- Death tests.
- Fatal and non-fatal failures.
- Value-parameterized tests.
- Type-parameterized tests.
- Various options for running the tests.
- XML test report generation.
GoogleTest requires a codebase and compiler compliant with the C++11 standard or newer.
The GoogleTest code is officially supported on the following platforms. Operating systems or tools not listed below are community-supported. For community-supported platforms, patches that do not complicate the code may be considered.
If you notice any problems on your platform, please file an issue on the GoogleTest GitHub Issue Tracker. Pull requests containing fixes are welcome!
- Linux
- macOS
- Windows
- gcc 5.0+
- clang 5.0+
- MSVC 2015+
macOS users: Xcode 9.3+ provides clang 5.0+.
Note: Bazel is the build system used by the team internally and in tests. CMake is supported on a best-effort basis and by the community.
In addition to many internal projects at Google, GoogleTest is also used by the following notable projects:
- The Chromium projects (behind the Chrome browser and Chrome OS).
- The LLVM compiler.
- Protocol Buffers, Google's data interchange format.
- The OpenCV computer vision library.
GTest Runner is a Qt5 based automated test-runner and Graphical User Interface with powerful features for Windows and Linux platforms.
GoogleTest UI is a test runner that runs your test binary, allows you to track its progress via a progress bar, and displays a list of test failures. Clicking on one shows failure text. GoogleTest UI is written in C#.
GTest TAP Listener is an event listener for GoogleTest that implements the TAP protocol for test result output. If your test runner understands TAP, you may find it useful.
gtest-parallel is a test runner that runs tests from your binary in parallel to provide significant speed-up.
GoogleTest Adapter is a VS Code extension allowing to view GoogleTest in a tree view, and run/debug your tests.
C++ TestMate is a VS Code extension allowing to view GoogleTest in a tree view, and run/debug your tests.
Cornichon is a small Gherkin DSL parser that generates stub code for GoogleTest.
Please read
CONTRIBUTING.md
for details on how to contribute to this project.
Happy testing!