Skip to content

Commit baf028f

Browse files
committed
doc: updated docs for generics and updated roadmap
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent e12affe commit baf028f

27 files changed

Lines changed: 1423 additions & 330 deletions

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Main features:
2525

2626
* zero external dependencies
2727
* opt-in dependencies for extra features (e.g. asserting YAML, colorized output)
28+
* assertions using generic types (see [a basic example][example-with-generics-url])
2829
* [searchable documentation][doc-url]
2930

3031
## Announcements
@@ -43,8 +44,15 @@ Design and exploration phase. Contributions and proposals are welcome.
4344

4445
> **Recent news**
4546
> Fully refactored how assertions are generated and documented.
47+
> Fixed hangs & panics when using `spew`. Fuzzed `spew`.
48+
> Fixed go routine leaks with `EventuallyWithT` and co.
49+
> Added `Kind` & `NotKind`
50+
> Fix deterministic order of keys in diff
51+
> Fixed edge cases with `InDelta`, `InEpsilon`
52+
> Added opt-in support for colorized output
53+
> Introduced generics (round 1): 16 new type-safe assertions with generic types (added benchmark)
4654
>
47-
> Now on our way to apply more fixes, features and adopt generics. See [ROADMAP][roadmap].
55+
> See our [ROADMAP][roadmap].
4856
4957
## Import this library in your project
5058

@@ -93,7 +101,7 @@ Becomes:
93101

94102
## Usage at go-openapi and go-swagger
95103

96-
This fork now full replaces the original project for all go-openapi projects,
104+
This fork now fully replaces the original project for all go-openapi projects,
97105
thus reducing their dependencies footprint.
98106

99107
Go-swagger will be adapted over Q1 2026.
@@ -161,6 +169,7 @@ Maintainers can cut a new release by either:
161169
<!-- Badges: documentation & support -->
162170
[doc-badge]: https://img.shields.io/badge/doc-site-blue?link=https%3A%2F%2Fgo-openapi.github.io%2Ftestify%2F
163171
[doc-url]: https://go-openapi.github.io/testify
172+
[example-with-generics-url]: https://go-openapi.github.io/testify#usage-with-generics
164173
[godoc-badge]: https://pkg.go.dev/badge/github.com/go-openapi/testify
165174
[godoc-url]: http://pkg.go.dev/github.com/go-openapi/testify
166175
[slack-logo]: https://a.slack-edge.com/e6a93c1/img/icons/favicon-32.png

codegen/internal/generator/templates/doc_index.md.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with all documented exported variants documented in a more concise form than the
2626
## Domains
2727

2828
The `testify` API is organized in {{ .RefCount }} domains shown below.
29+
Each domain contains assertions regrouped by their use case (e.g. http, json, error).
2930

3031
{{ print "{{" }}< children type="card" description="true" >{{ print "}}" }}
3132

codegen/internal/generator/templates/doc_page.md.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Generic assertions are marked with a {{ print "{{" }}% icon icon="star" color=or
4141
{{- range .Functions }}{{/* functions in internal/assertions annotated with "domain:" */}}
4242
{{- if or (not .IsGeneric) ($enableGenerics) }}
4343
{{- if and (not .IsHelper) (not .IsConstructor) }}
44-
- [{{ .GenericName }}](#{{ slugize .GenericName }}) | {{ if .IsGeneric}}star | orange {{ else }}angles-right{{ end }}
44+
- [{{ .GenericName }}](#{{ slugize .GenericName }}) | {{ if .IsGeneric}}star | orange{{ else }}angles-right{{ end }}
4545
{{- end }}
4646
{{- end }}
4747
{{- end }}

docs/doc-site/_index.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
22
title: "Testify v2"
33
type: home
4-
description: 'Go testing assertions for the rest of us'
4+
description: 'The v2 our test wanted'
55
weight: 1
66
---
77

8-
**Go testing assertions for the rest of us**
9-
108
{{% notice info %}}
119
This is the home of `github.com/go-openapi/testify/v2`, an active, opinionated fork of `github.com/stretchr/testify`.
1210
{{% /notice %}}
1311

1412
## Testify v2 - The v2 our tests wanted
1513

16-
A set of `go` packages that provide tools for testifying that your code behaves as you intended.
14+
A set of `go` packages that provide tools for _testifying_ (verifying) that your code behaves as you intended.
1715

1816
This is the go-openapi fork of the great [testify](https://github.com/stretchr/testify) package.
1917

@@ -44,7 +42,9 @@ APIs that became bloated over a decade or so, uncontrolled dependencies, difficu
4442
breaking changes, conflicting demands from users etc.
4543
{{% /notice %}}
4644

47-
More about our motivations in the project's [README](README.md).
45+
More about our motivations in the project's [README](README.md#motivation).
46+
47+
You might also be curious about our [ROADMAP](project/maintainers/ROADMAP.md).
4848

4949
### Getting started
5050

@@ -86,6 +86,7 @@ To use this package in your projects:
8686
```go
8787
import (
8888
"testing"
89+
8990
"github.com/go-openapi/testify/v2/require"
9091
)
9192
...
@@ -101,6 +102,33 @@ To use this package in your projects:
101102
{{% /card %}}
102103
{{< /cards >}}
103104

105+
### Usage with generics
106+
107+
Assertion functions that support go generic types are suffixed with `T` (for "Type safety").
108+
A formatted variant suffixed with `Tf` is also exposed.
109+
110+
Obviously, the `Assertion` type cannot be extended with generic methods, as of `go1.25`.
111+
112+
{{% card title="InDeltaT" %}}
113+
```go
114+
import (
115+
"testing"
116+
117+
"github.com/go-openapi/testify/v2/require"
118+
)
119+
...
120+
121+
const (
122+
expected = 1.00
123+
delta = 1E-6
124+
)
125+
var input = 1.01
126+
127+
result := someComplexComputation(input)
128+
require.InDeltaT(t, expected, input, delta)
129+
```
130+
{{% /card %}}
131+
104132
## Licensing
105133

106134
`SPDX-FileCopyrightText: Copyright 2025 go-swagger maintainers`

docs/doc-site/api/_index.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: |
66
77
Find the assertion function you need for your data.
88
weight: 1
9-
modified: 2026-01-11
9+
modified: 2026-01-18
1010
---
1111

1212
**Go testing assertions for the rest of us**
@@ -26,28 +26,29 @@ with all documented exported variants documented in a more concise form than the
2626
## Domains
2727

2828
The `testify` API is organized in 18 domains shown below.
29+
Each domain contains assertions regrouped by their use case (e.g. http, json, error).
2930

3031
{{< children type="card" description="true" >}}
3132

3233
---
3334

34-
- [Boolean](./boolean.md) - Asserting Boolean Values (2)
35-
- [Collection](./collection.md) - Asserting Slices And Maps (7)
36-
- [Comparison](./comparison.md) - Comparing Ordered Values (6)
35+
- [Boolean](./boolean.md) - Asserting Boolean Values (4)
36+
- [Collection](./collection.md) - Asserting Slices And Maps (9)
37+
- [Comparison](./comparison.md) - Comparing Ordered Values (12)
3738
- [Condition](./condition.md) - Expressing Assertions Using Conditions (4)
3839
- [Equality](./equality.md) - Asserting Two Things Are Equal (12)
3940
- [Error](./error.md) - Asserting Errors (8)
4041
- [File](./file.md) - Asserting OS Files (6)
4142
- [Http](./http.md) - Asserting HTTP Response And Body (7)
42-
- [Json](./json.md) - Asserting JSON Documents (2)
43-
- [Number](./number.md) - Asserting Numbers (5)
43+
- [Json](./json.md) - Asserting JSON Documents (3)
44+
- [Number](./number.md) - Asserting Numbers (7)
4445
- [Ordering](./ordering.md) - Asserting How Collections Are Ordered (4)
4546
- [Panic](./panic.md) - Asserting A Panic Behavior (4)
46-
- [String](./string.md) - Asserting Strings (2)
47+
- [String](./string.md) - Asserting Strings (4)
4748
- [Testing](./testing.md) - Mimicks Methods From The Testing Standard Library (2)
4849
- [Time](./time.md) - Asserting Times And Durations (2)
4950
- [Type](./type.md) - Asserting Types Rather Than Values (8)
50-
- [Yaml](./yaml.md) - Asserting Yaml Documents (1)
51+
- [Yaml](./yaml.md) - Asserting Yaml Documents (3)
5152
- [Common](./common.md) - Other Uncategorized Helpers (4)
5253

5354
---
@@ -66,5 +67,5 @@ SPDX-License-Identifier: Apache-2.0
6667
6768
Document generated by github.com/go-openapi/testify/codegen/v2 DO NOT EDIT.
6869
69-
Generated on 2026-01-11 (version ca82e58) using codegen version v2.1.9-0.20260111184010-ca82e58db12c+dirty [sha: ca82e58db12cbb61bfcae58c3684b3add9599d10]
70+
Generated on 2026-01-18 (version e12affe) using codegen version v2.1.9-0.20260118112101-e12affef2419+dirty [sha: e12affef24198e72ee13eb6d25018d2c3232629f]
7071
-->

docs/doc-site/api/boolean.md

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
22
title: "Boolean"
33
description: "Asserting Boolean Values"
4-
modified: 2026-01-11
4+
modified: 2026-01-18
55
weight: 1
66
domains:
77
- "boolean"
88
keywords:
99
- "False"
1010
- "Falsef"
11+
- "FalseT"
12+
- "FalseTf"
1113
- "True"
1214
- "Truef"
15+
- "TrueT"
16+
- "TrueTf"
1317
---
1418

1519
Asserting Boolean Values
@@ -21,9 +25,17 @@ Asserting Boolean Values
2125

2226
_All links point to <https://pkg.go.dev/github.com/go-openapi/testify/v2>_
2327

24-
This domain exposes 2 functionalities.
28+
This domain exposes 4 functionalities.
29+
Generic assertions are marked with a {{% icon icon="star" color=orange %}}
2530

26-
### False
31+
```tree
32+
- [False](#false) | angles-right
33+
- [FalseT[B Boolean]](#falsetb-boolean) | star | orange
34+
- [True](#true) | angles-right
35+
- [TrueT[B Boolean]](#truetb-boolean) | star | orange
36+
```
37+
38+
### False{#false}
2739

2840
False asserts that the specified value is false.
2941

@@ -66,11 +78,56 @@ False asserts that the specified value is false.
6678
|--|--|
6779
| [`assertions.False(t T, value bool, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#False) | internal implementation |
6880

69-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#False](https://github.com/go-openapi/testify/blob/master/internal/assertions/boolean.go#L38)
81+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#False](https://github.com/go-openapi/testify/blob/master/internal/assertions/boolean.go#L63)
82+
{{% /tab %}}
83+
{{< /tabs >}}
84+
85+
### FalseT[B Boolean] {{% icon icon="star" color=orange %}}{#falsetb-boolean}
86+
87+
FalseT asserts that the specified value is false.
88+
89+
{{% expand title="Examples" %}}
90+
{{< tabs >}}
91+
{{% tab title="Usage" %}}
92+
```go
93+
type B bool
94+
var b B = true
95+
assertions.FalseT(t, b)
96+
```
97+
{{< /tab >}}
98+
{{% tab title="Examples" %}}
99+
```go
100+
success: 1 == 0
101+
failure: 1 == 1
102+
```
103+
{{< /tab >}}
104+
{{< /tabs >}}
105+
{{% /expand %}}
106+
107+
{{< tabs >}}
108+
{{% tab title="assert" style="secondary" %}}
109+
| Signature | Usage |
110+
|--|--|
111+
| [`assert.FalseT[B Boolean](t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#FalseT) | package-level function |
112+
| [`assert.FalseTf[B Boolean](t T, value B, msg string, args ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#FalseTf) | formatted variant |
113+
{{% /tab %}}
114+
{{% tab title="require" style="secondary" %}}
115+
| Signature | Usage |
116+
|--|--|
117+
| [`require.FalseT[B Boolean](t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/require#FalseT) | package-level function |
118+
| [`require.FalseTf[B Boolean](t T, value B, msg string, args ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/require#FalseTf) | formatted variant |
119+
{{% /tab %}}
120+
121+
{{% tab title="internal" style="accent" icon="wrench" %}}
122+
| Signature | Usage |
123+
|--|--|
124+
| [`assertions.FalseT(t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#FalseT) | internal implementation |
125+
126+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#FalseT](https://github.com/go-openapi/testify/blob/master/internal/assertions/boolean.go#L88)
70127
{{% /tab %}}
71128
{{< /tabs >}}
72129

73-
### True
130+
### True{#true}
74131

75132
True asserts that the specified value is true.
76133

@@ -117,6 +174,51 @@ True asserts that the specified value is true.
117174
{{% /tab %}}
118175
{{< /tabs >}}
119176

177+
### TrueT[B Boolean] {{% icon icon="star" color=orange %}}{#truetb-boolean}
178+
179+
TrueT asserts that the specified value is true.
180+
181+
{{% expand title="Examples" %}}
182+
{{< tabs >}}
183+
{{% tab title="Usage" %}}
184+
```go
185+
type B bool
186+
var b B = true
187+
assertions.True(t, b)
188+
```
189+
{{< /tab >}}
190+
{{% tab title="Examples" %}}
191+
```go
192+
success: 1 == 1
193+
failure: 1 == 0
194+
```
195+
{{< /tab >}}
196+
{{< /tabs >}}
197+
{{% /expand %}}
198+
199+
{{< tabs >}}
200+
{{% tab title="assert" style="secondary" %}}
201+
| Signature | Usage |
202+
|--|--|
203+
| [`assert.TrueT[B Boolean](t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#TrueT) | package-level function |
204+
| [`assert.TrueTf[B Boolean](t T, value B, msg string, args ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#TrueTf) | formatted variant |
205+
{{% /tab %}}
206+
{{% tab title="require" style="secondary" %}}
207+
| Signature | Usage |
208+
|--|--|
209+
| [`require.TrueT[B Boolean](t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/require#TrueT) | package-level function |
210+
| [`require.TrueTf[B Boolean](t T, value B, msg string, args ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/require#TrueTf) | formatted variant |
211+
{{% /tab %}}
212+
213+
{{% tab title="internal" style="accent" icon="wrench" %}}
214+
| Signature | Usage |
215+
|--|--|
216+
| [`assertions.TrueT(t T, value B, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#TrueT) | internal implementation |
217+
218+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#TrueT](https://github.com/go-openapi/testify/blob/master/internal/assertions/boolean.go#L41)
219+
{{% /tab %}}
220+
{{< /tabs >}}
221+
120222
---
121223

122224
---
@@ -133,5 +235,5 @@ SPDX-License-Identifier: Apache-2.0
133235
134236
Document generated by github.com/go-openapi/testify/codegen/v2 DO NOT EDIT.
135237
136-
Generated on 2026-01-11 (version ca82e58) using codegen version v2.1.9-0.20260111184010-ca82e58db12c+dirty [sha: ca82e58db12cbb61bfcae58c3684b3add9599d10]
238+
Generated on 2026-01-18 (version e12affe) using codegen version v2.1.9-0.20260118112101-e12affef2419+dirty [sha: e12affef24198e72ee13eb6d25018d2c3232629f]
137239
-->

0 commit comments

Comments
 (0)