# stretchr/testify architecture

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

- Interactive diagram: https://gitdiagram.com/stretchr/testify
- Repository: https://github.com/stretchr/testify

## Overview

Testify is a Go testing-support library: test authors use assertions to check outcomes, and can choose immediate-failure requirements, expectation-based mocks, or structured suites. Assertions also provide specialized HTTP and YAML checks; internal formatting and diff utilities support readable failures. The suite runner manages test methods, subtests, and setup/teardown hooks. Edges reflect only relationships shown in the README or sampled source references; mock internals and HTTP helper wiring were not sampled, so no internal call flow is inferred for them.

Main entry points: [`assert/assertions.go`](https://github.com/stretchr/testify/blob/master/assert/assertions.go) (Assertions), [`suite/suite.go`](https://github.com/stretchr/testify/blob/master/suite/suite.go) (Suite execution), [`require/require.go`](https://github.com/stretchr/testify/blob/master/require/require.go) (Fail-fast checks), [`mock/mock.go`](https://github.com/stretchr/testify/blob/master/mock/mock.go) (Mock expectations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_assertions["Assertion APIs"]
  node_assert["Assertions<br/>[assertions.go]"]
  node_require["Fail-fast checks<br/>[require.go]"]
end

subgraph group_test_doubles["Test Doubles"]
  node_mock["Mock expectations<br/>[mock.go]"]
  node_http_helpers["HTTP test helpers"]
end

subgraph group_suite_runner["Suite Runner"]
  node_suite["Suite execution<br/>[suite.go]"]
end

subgraph group_support["Assertion Support"]
  node_yaml["YAML comparison<br/>[yaml_default.go]"]
  node_difflib["Text diffs<br/>[difflib.go]"]
  node_spew["Value formatting<br/>[dump.go]"]
end

node_author(("Test author"))

node_author -->|"checks outcomes"| node_assert
node_author -->|"checks or aborts"| node_require
node_author -->|"sets expectations"| node_mock
node_author -->|"runs suite"| node_suite
node_require -->|"delegates checks"| node_assert
node_suite -->|"provides context"| node_assert
node_suite -->|"provides context"| node_require
node_assert -->|"compares YAML"| node_yaml
node_assert -->|"builds diffs"| node_difflib
node_assert -->|"formats values"| node_spew

click node_assert "https://github.com/stretchr/testify/blob/master/assert/assertions.go"
click node_require "https://github.com/stretchr/testify/blob/master/require/require.go"
click node_mock "https://github.com/stretchr/testify/blob/master/mock/mock.go"
click node_suite "https://github.com/stretchr/testify/blob/master/suite/suite.go"
click node_http_helpers "https://github.com/stretchr/testify/blob/master/http/test_response_writer.go"
click node_yaml "https://github.com/stretchr/testify/blob/master/assert/yaml/yaml_default.go"
click node_difflib "https://github.com/stretchr/testify/blob/master/internal/difflib/difflib.go"
click node_spew "https://github.com/stretchr/testify/blob/master/internal/spew/dump.go"

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_assert,node_require toneBlue
class node_mock,node_http_helpers toneAmber
class node_suite toneMint
class node_yaml,node_difflib,node_spew toneRose
class node_author toneIndigo
```

## Components

### Assertion APIs

- [Assertions](https://github.com/stretchr/testify/blob/master/assert/assertions.go): `assert/assertions.go`
- [Fail-fast checks](https://github.com/stretchr/testify/blob/master/require/require.go): `require/require.go`

### Test Doubles

- [Mock expectations](https://github.com/stretchr/testify/blob/master/mock/mock.go): `mock/mock.go`
- [HTTP test helpers](https://github.com/stretchr/testify/blob/master/http/test_response_writer.go): `http/test_response_writer.go`

### Suite Runner

- [Suite execution](https://github.com/stretchr/testify/blob/master/suite/suite.go): `suite/suite.go`

### Assertion Support

- [YAML comparison](https://github.com/stretchr/testify/blob/master/assert/yaml/yaml_default.go): `assert/yaml/yaml_default.go`
- [Text diffs](https://github.com/stretchr/testify/blob/master/internal/difflib/difflib.go): `internal/difflib/difflib.go`
- [Value formatting](https://github.com/stretchr/testify/blob/master/internal/spew/dump.go): `internal/spew/dump.go`

### Other components

- **Test author**

## Connections

- Test author → Assertions: checks outcomes (evidence: `README.md`)
- Test author → Fail-fast checks: checks or aborts (evidence: `README.md`)
- Test author → Mock expectations: sets expectations (evidence: `README.md`)
- Test author → Suite execution: runs suite (evidence: `README.md`)
- Fail-fast checks → Assertions: delegates checks (evidence: `require/require.go`)
- Suite execution → Assertions: provides context (evidence: `suite/suite.go`)
- Suite execution → Fail-fast checks: provides context (evidence: `suite/suite.go`)
- Assertions → YAML comparison: compares YAML (evidence: `assert/assertions.go`)
- Assertions → Text diffs: builds diffs (evidence: `assert/assertions.go`)
- Assertions → Value formatting: formats values (evidence: `assert/assertions.go`)
