# surya-narayan-m/catch2 architecture

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

- Interactive diagram: https://gitdiagram.com/surya-narayan-m/catch2
- Repository: https://github.com/surya-narayan-m/catch2

## Overview

Catch2 is a C++ testing framework with microbenchmarking and BDD macros. A user writes tests and assertions, then runs the framework to execute selected tests and produce reports. The tree shows distinct session, configuration, registry, execution, assertion, matcher, generator, and reporter modules; the README documents the user-facing capabilities. Most implementation relationships are not established by the available excerpts or reference index, so unverified runtime links are dashed rather than presented as inspected calls.

Main entry points: [`src/catch2/internal/catch_run_context.cpp`](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_run_context.cpp) (Test execution), [`src/catch2/catch_session.cpp`](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_session.cpp) (Session runner), [`src/catch2/internal/catch_reporter_registry.cpp`](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_reporter_registry.cpp) (Reporter setup), [`src/catch2/catch_test_macros.hpp`](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_test_macros.hpp) (Test and BDD macros)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Test entry"]
  node_test_macros["Test and BDD macros"]
  node_session["Session runner<br/>[catch_session.cpp]"]
  node_configuration["Run configuration<br/>[catch_config.cpp]"]
  node_amalgamated["Amalgamated distribution"]
end

subgraph group_runtime["Test runtime"]
  node_registry[("Test registry")]
  node_selection["Test selection"]
  node_execution["Test execution"]
  node_sections["Section tracking<br/>[catch_section.cpp]"]
  node_assertions["Assertion handling"]
end

subgraph group_extensions["Test extensions"]
  node_generators["Test generators"]
  node_matchers["Matchers<br/>[catch_matchers.hpp]"]
  node_benchmarks["Microbenchmarks"]
end

subgraph group_reporting["Reporting"]
  node_reporter_setup["Reporter setup"]
  node_console_reporter["Console reporter"]
  node_json_reporter["JSON reporter"]
  node_xml_reporter["XML reporter"]
end

node_test_author(("Test author"))

node_test_author -->|"writes tests"| node_test_macros
node_test_author -->|"writes benchmarks"| node_benchmarks
node_test_macros -.->|"registers tests"| node_registry
node_session -.->|"uses config"| node_configuration
node_session -.->|"selects tests"| node_selection
node_session -.->|"runs tests"| node_execution
node_session -.->|"sets up reports"| node_reporter_setup
node_execution -.->|"loads tests"| node_registry
node_execution -.->|"tracks sections"| node_sections
node_execution -.->|"handles assertions"| node_assertions
node_execution -.->|"uses generators"| node_generators
node_execution -.->|"evaluates matchers"| node_matchers
node_reporter_setup -.->|"selects reporter"| node_console_reporter
node_reporter_setup -.->|"selects reporter"| node_json_reporter
node_reporter_setup -.->|"selects reporter"| node_xml_reporter

click node_test_macros "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_test_macros.hpp"
click node_session "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_session.cpp"
click node_configuration "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_config.cpp"
click node_registry "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_test_registry.cpp"
click node_selection "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_test_spec.cpp"
click node_execution "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_run_context.cpp"
click node_sections "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_section.cpp"
click node_assertions "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_assertion_handler.cpp"
click node_generators "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/generators/catch_generators.hpp"
click node_matchers "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/matchers/catch_matchers.hpp"
click node_benchmarks "https://github.com/surya-narayan-m/catch2/tree/devel/src/catch2"
click node_reporter_setup "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_reporter_registry.cpp"
click node_console_reporter "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_console.cpp"
click node_json_reporter "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_json.cpp"
click node_xml_reporter "https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_xml.cpp"
click node_amalgamated "https://github.com/surya-narayan-m/catch2/blob/devel/extras/catch_amalgamated.cpp"

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_test_macros,node_session,node_configuration,node_amalgamated toneBlue
class node_registry,node_selection,node_execution,node_sections,node_assertions toneAmber
class node_generators,node_matchers,node_benchmarks toneMint
class node_reporter_setup,node_console_reporter,node_json_reporter,node_xml_reporter toneRose
class node_test_author toneIndigo
```

## Components

### Test entry

- [Test and BDD macros](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_test_macros.hpp): `src/catch2/catch_test_macros.hpp`
- [Session runner](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_session.cpp): `src/catch2/catch_session.cpp`
- [Run configuration](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_config.cpp): `src/catch2/catch_config.cpp`
- [Amalgamated distribution](https://github.com/surya-narayan-m/catch2/blob/devel/extras/catch_amalgamated.cpp): `extras/catch_amalgamated.cpp`

### Test runtime

- [Test registry](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_test_registry.cpp): `src/catch2/internal/catch_test_registry.cpp`
- [Test selection](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/catch_test_spec.cpp): `src/catch2/catch_test_spec.cpp`
- [Test execution](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_run_context.cpp): `src/catch2/internal/catch_run_context.cpp`
- [Section tracking](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_section.cpp): `src/catch2/internal/catch_section.cpp`
- [Assertion handling](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_assertion_handler.cpp): `src/catch2/internal/catch_assertion_handler.cpp`

### Test extensions

- [Test generators](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/generators/catch_generators.hpp): `src/catch2/generators/catch_generators.hpp`
- [Matchers](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/matchers/catch_matchers.hpp): `src/catch2/matchers/catch_matchers.hpp`
- [Microbenchmarks](https://github.com/surya-narayan-m/catch2/tree/devel/src/catch2): `src/catch2`

### Reporting

- [Reporter setup](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/internal/catch_reporter_registry.cpp): `src/catch2/internal/catch_reporter_registry.cpp`
- [Console reporter](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_console.cpp): `src/catch2/reporters/catch_reporter_console.cpp`
- [JSON reporter](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_json.cpp): `src/catch2/reporters/catch_reporter_json.cpp`
- [XML reporter](https://github.com/surya-narayan-m/catch2/blob/devel/src/catch2/reporters/catch_reporter_xml.cpp): `src/catch2/reporters/catch_reporter_xml.cpp`

### Other components

- **Test author**

## Connections

- Test author → Test and BDD macros: writes tests (evidence: `README.md`)
- Test author → Microbenchmarks: writes benchmarks (evidence: `README.md`)
- Test and BDD macros → Test registry: registers tests
- Session runner → Run configuration: uses config
- Session runner → Test selection: selects tests
- Session runner → Test execution: runs tests
- Session runner → Reporter setup: sets up reports
- Test execution → Test registry: loads tests
- Test execution → Section tracking: tracks sections
- Test execution → Assertion handling: handles assertions
- Test execution → Test generators: uses generators
- Test execution → Matchers: evaluates matchers
- Reporter setup → Console reporter: selects reporter
- Reporter setup → JSON reporter: selects reporter
- Reporter setup → XML reporter: selects reporter
