# google/googletest architecture

> Architecture diagram of the GitHub repository google/googletest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/googletest
- Repository: https://github.com/google/googletest

## Overview

GoogleTest is a C++ test framework, bundled with GoogleMock. Test authors define tests and assertions; the framework discovers and runs tests, records failures, and reports results. Its capabilities include death, value-parameterized, and type-parameterized tests; GoogleMock adds expectation matching and configurable actions. The graph groups public test authoring, execution and support, and mocking. Edges are limited to README statements and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`googletest/include/gtest/gtest.h`](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest.h) (Test API), [`googlemock/include/gmock/gmock.h`](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock.h) (Mock API), [`googlemock/include/gmock/gmock-spec-builders.h`](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-spec-builders.h) (Expectations), [`googlemock/include/gmock/gmock-matchers.h`](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-matchers.h) (Mock matchers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Test authoring"]
  node_gtest_api["Test API<br/>[gtest.h]"]
  node_assertions["Assertions"]
  node_death["Death tests<br/>[gtest-death-test.h]"]
  node_value_params["Value parameters<br/>[gtest-param-test.h]"]
  node_type_params["Type parameters<br/>[gtest-typed-test.h]"]
end

subgraph group_execution["Test execution"]
  node_runner["Test runner<br/>[gtest.cc]"]
  node_registry["Test registry"]
  node_test_parts["Test results<br/>[gtest-test-part.h]"]
end

subgraph group_support["Runtime support"]
  node_printers["Value printers<br/>[gtest-printers.h]"]
  node_messages["Messages<br/>[gtest-message.h]"]
  node_internal["Test internals<br/>[gtest-internal.h]"]
  node_portability["Platform support<br/>[gtest-port.h]"]
  node_strings["String utilities<br/>[gtest-string.h]"]
end

subgraph group_mocking["Mock behavior"]
  node_gmock_api["Mock API<br/>[gmock.h]"]
  node_expectations["Expectations"]
  node_actions["Mock actions<br/>[gmock-actions.h]"]
  node_cardinalities["Call counts"]
  node_mock_matchers["Mock matchers<br/>[gmock-matchers.h]"]
  node_mock_utils["Mock utilities"]
  node_mock_port["Mock portability<br/>[gmock-port.h]"]
  node_mock_pp["Mock macros<br/>[gmock-pp.h]"]
end

node_author(("Test author"))

node_author -->|"defines tests"| node_gtest_api
node_author -->|"uses mocks"| node_gmock_api
node_gtest_api -->|"includes"| node_assertions
node_gtest_api -->|"includes"| node_death
node_gtest_api -->|"includes"| node_value_params
node_gtest_api -->|"includes"| node_type_params
node_gtest_api -->|"includes"| node_internal
node_gtest_api -->|"includes"| node_messages
node_gtest_api -->|"includes"| node_test_parts
node_runner -->|"uses"| node_registry
node_runner -.->|"records failures"| node_test_parts
node_internal -->|"uses"| node_portability
node_internal -->|"uses"| node_strings
node_gtest_api -->|"includes"| node_printers
node_gmock_api -->|"includes"| node_expectations
node_gmock_api -->|"includes"| node_actions
node_gmock_api -->|"includes"| node_cardinalities
node_gmock_api -->|"includes"| node_mock_matchers
node_expectations -->|"uses"| node_actions
node_expectations -->|"uses"| node_cardinalities
node_expectations -->|"uses"| node_mock_matchers
node_mock_matchers -->|"uses"| node_mock_utils
node_mock_utils -->|"uses"| node_mock_port
node_mock_port -->|"uses"| node_portability
node_actions -->|"uses"| node_mock_utils
node_mock_matchers -->|"uses"| node_mock_pp

click node_gtest_api "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest.h"
click node_assertions "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-assertion-result.h"
click node_death "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-death-test.h"
click node_value_params "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-param-test.h"
click node_type_params "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-typed-test.h"
click node_runner "https://github.com/google/googletest/blob/main/googletest/src/gtest.cc"
click node_registry "https://github.com/google/googletest/blob/main/googletest/src/gtest-internal-inl.h"
click node_test_parts "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-test-part.h"
click node_printers "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-printers.h"
click node_messages "https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-message.h"
click node_internal "https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-internal.h"
click node_portability "https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-port.h"
click node_strings "https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-string.h"
click node_gmock_api "https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock.h"
click node_expectations "https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-spec-builders.h"
click node_actions "https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-actions.h"
click node_cardinalities "https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-cardinalities.h"
click node_mock_matchers "https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-matchers.h"
click node_mock_utils "https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-internal-utils.h"
click node_mock_port "https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-port.h"
click node_mock_pp "https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-pp.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gtest_api,node_assertions,node_death,node_value_params,node_type_params toneBlue
class node_runner,node_registry,node_test_parts toneAmber
class node_printers,node_messages,node_internal,node_portability,node_strings toneMint
class node_gmock_api,node_expectations,node_actions,node_cardinalities,node_mock_matchers,node_mock_utils,node_mock_port,node_mock_pp toneRose
class node_author toneIndigo
```

## Components

### Test authoring

- [Test API](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest.h): `googletest/include/gtest/gtest.h`
- [Assertions](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-assertion-result.h): `googletest/include/gtest/gtest-assertion-result.h`
- [Death tests](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-death-test.h): `googletest/include/gtest/gtest-death-test.h`
- [Value parameters](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-param-test.h): `googletest/include/gtest/gtest-param-test.h`
- [Type parameters](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-typed-test.h): `googletest/include/gtest/gtest-typed-test.h`

### Test execution

- [Test runner](https://github.com/google/googletest/blob/main/googletest/src/gtest.cc): `googletest/src/gtest.cc`
- [Test registry](https://github.com/google/googletest/blob/main/googletest/src/gtest-internal-inl.h): `googletest/src/gtest-internal-inl.h`
- [Test results](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-test-part.h): `googletest/include/gtest/gtest-test-part.h`

### Runtime support

- [Value printers](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-printers.h): `googletest/include/gtest/gtest-printers.h`
- [Messages](https://github.com/google/googletest/blob/main/googletest/include/gtest/gtest-message.h): `googletest/include/gtest/gtest-message.h`
- [Test internals](https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-internal.h): `googletest/include/gtest/internal/gtest-internal.h`
- [Platform support](https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-port.h): `googletest/include/gtest/internal/gtest-port.h`
- [String utilities](https://github.com/google/googletest/blob/main/googletest/include/gtest/internal/gtest-string.h): `googletest/include/gtest/internal/gtest-string.h`

### Mock behavior

- [Mock API](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock.h): `googlemock/include/gmock/gmock.h`
- [Expectations](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-spec-builders.h): `googlemock/include/gmock/gmock-spec-builders.h`
- [Mock actions](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-actions.h): `googlemock/include/gmock/gmock-actions.h`
- [Call counts](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-cardinalities.h): `googlemock/include/gmock/gmock-cardinalities.h`
- [Mock matchers](https://github.com/google/googletest/blob/main/googlemock/include/gmock/gmock-matchers.h): `googlemock/include/gmock/gmock-matchers.h`
- [Mock utilities](https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-internal-utils.h): `googlemock/include/gmock/internal/gmock-internal-utils.h`
- [Mock portability](https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-port.h): `googlemock/include/gmock/internal/gmock-port.h`
- [Mock macros](https://github.com/google/googletest/blob/main/googlemock/include/gmock/internal/gmock-pp.h): `googlemock/include/gmock/internal/gmock-pp.h`

### Other components

- **Test author**

## Connections

- Test author → Test API: defines tests
- Test author → Mock API: uses mocks
- Test API → Assertions: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Death tests: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Value parameters: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Type parameters: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Test internals: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Messages: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test API → Test results: includes (evidence: `googletest/include/gtest/gtest.h`)
- Test runner → Test registry: uses (evidence: `googletest/src/gtest.cc`)
- Test runner → Test results: records failures
- Test internals → Platform support: uses (evidence: `googletest/include/gtest/internal/gtest-internal.h`)
- Test internals → String utilities: uses (evidence: `googletest/include/gtest/internal/gtest-internal.h`)
- Test API → Value printers: includes (evidence: `googletest/include/gtest/gtest.h`)
- Mock API → Expectations: includes (evidence: `googlemock/include/gmock/gmock.h`)
- Mock API → Mock actions: includes (evidence: `googlemock/include/gmock/gmock.h`)
- Mock API → Call counts: includes (evidence: `googlemock/include/gmock/gmock.h`)
- Mock API → Mock matchers: includes (evidence: `googlemock/include/gmock/gmock.h`)
- Expectations → Mock actions: uses (evidence: `googlemock/include/gmock/gmock-spec-builders.h`)
- Expectations → Call counts: uses (evidence: `googlemock/include/gmock/gmock-spec-builders.h`)
- Expectations → Mock matchers: uses (evidence: `googlemock/include/gmock/gmock-spec-builders.h`)
- Mock matchers → Mock utilities: uses (evidence: `googlemock/include/gmock/gmock-matchers.h`)
- Mock utilities → Mock portability: uses (evidence: `googlemock/include/gmock/internal/gmock-internal-utils.h`)
- Mock portability → Platform support: uses (evidence: `googlemock/include/gmock/internal/gmock-port.h`)
- Mock actions → Mock utilities: uses (evidence: `googlemock/include/gmock/gmock-actions.h`)
- Mock matchers → Mock macros: uses (evidence: `googlemock/include/gmock/gmock-matchers.h`)
