Google Test

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Google Test
Stable release
1.8.1 / August 31, 2018; 9 months ago (2018-08-31)
Written inC++
Operating systemLinux, Microsoft Windows, macOS
TypeUnit testing tool
LicenseBSD 3-clauses

Google Test (also known as gtest for e.g. the ROS environment[1]) is a unit testing library for the C++ programming language, based on the xUnit architecture.[2] The library is released under the BSD 3-clause license.[3] It can be compiled for a variety of POSIX and Windows platforms, allowing unit-testing of C sources as well as C++ with minimal source modification. The tests themselves could be run one at a time, or even be called to run all at once. This makes the debugging process very specific and caters to the need of many programmers and coders alike.

Types of Google Tests[edit]

Google introduced its own classification of test types.[4] Instead of categorizations like unit, functional or integration test they have only three categories: small, medium, and large scale tests:

Small Tests (Unit Tests)[edit]

Small tests are mostly (but not always) automated and exercise the code within a single function or module. The focus is on typical functional issues, data corruption, error conditions, and off-by-one mistakes. Small tests are of short duration, usually running in seconds or less. They are most likely written by a software engineer (SWE), less often by a software engineer in test (SET), and hardly ever by a test engineer (TE).[5] Small tests generally require sample environments to run and be tested in. TEs rarely write small tests but might run them when they are trying to diagnose a particular failure. The question a small test attempts to answer is, “Does this code do what it is supposed to do?”[5]

Medium Tests (Integration Tests)[edit]

Medium tests are usually automated and involve two or more interacting features. The focus is on testing the interaction between features that call each other or interact directly.[5] Software engineers drive the development of these tests early in the product cycle as individual features are completed and developers are heavily involved in writing, debugging, and maintaining the actual tests. If a medium test fails or breaks, the developer takes care of it autonomously. The question a medium test attempts to answer is, “Does a set of near adjacent functions operate with each other the way they are supposed to?”[5]

Large Tests (Acceptance Tests)[edit]

Large tests cover three or more features and represent real user scenarios with real user data sources. There is some concern with overall integration of the features, but large tests tend to be more results-driven, checking that the software satisfies user needs. All three roles are involved in writing large tests and everything from automation to exploratory testing can be the vehicle to accomplish them. The question a large test attempts to answer is, “Does the product operate the way a user would expect and produce the desired results?”[6]


This test will fail under the condition that the code has failed during a test case or the test process itself. In other words; when the code breaks, the test is failed.[7]


The test should not fail if a test case does not pass. The test only fails when there is a breaking change that is implemented to the code being tested.[7]


When the test fails, the exact error will be located and notified to the tester. This type of test does not work well with functions that rely on string inputs.[7]


  • Basic Test [2]
  • Floating Point Comparisons [2]
  • Death Test [2]

Projects using Google Test[edit]

Besides being developed and used at Google, many other projects implement Google Test as well:

Related tools[edit]

Google Test UI is test runner that runs one's test binary, allows one to track its progress via a progress bar, and displays a list of test failures. Clicking on one shows failure text. Google Test UI is written in C#.[9] Additionally, a feature-complete Visual Studio extension exists with Google Test Adapter.[10]

Popular tools used in Chrome with association to Google Test:

  • Developer tools: Look at the page’s elements, resources, and scripts, and enable resource tracking.
  • JavaScript Console: Does JavaScript in the Console execute correctly?
  • Viewing source code: Is it easy to read through the use of color coding and other help, and is it easy to get to a relevant section?
  • Task Manager: Do processes show up correctly and is it easy to see how many resources the web page consumes?[11]

See also[edit]


  1. ^ Google Test (gtest) in the wiki of
  2. ^ a b c d A quick introduction to the Google C++ Testing Framework, Arpan Sen, IBM DeveloperWorks, 2010-05-11, retrieved 2016-04-12
  3. ^ Google Test's repository, retrieved 2016-04-12, cites New BSD as license. The license file is at
  4. ^ Test Sizes, retrieved 2015-04-16
  5. ^ a b c d Whittaker 2012, p. 12.
  6. ^ Whittaker 2012, p. 13.
  7. ^ a b c The Google Test and Development Environment, Anthony Vallone, 2014-01-21, retrieved 201-05-10
  8. ^ Gromacs Testing Framework
  9. ^ Google Test UI retrieved 2016-04-12
  10. ^ [1]
  11. ^ Whittaker 2012, p. 251.

Further reading[edit]

  • Whittaker, James (2012). How Google Tests Software. Boston, Massachusetts: Pearson Education. ISBN 0-321-80302-7.

External links[edit]