Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit a8a17a8

Browse files
authored
Improve documentation (#93)
1 parent f47274a commit a8a17a8

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed

README.md

+59-9
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,42 @@ $ go test
6060
want: "ok"
6161
```
6262

63+
⚠ Do not forget calling
64+
[`Assert(t)`](https://pkg.go.dev/github.com/fluentassert/verify#FailureMessage.Assert)
65+
or [`Require(t)`](https://pkg.go.dev/github.com/fluentassert/verify#FailureMessage.Require)
66+
which executes the actual assertion.
67+
68+
## Supported types
69+
70+
Out-of-the-box the package provides fluent assertions for the following types.
71+
The more specific function you use, the more assertions you get.
72+
73+
| Go type | Assertion entry point |
74+
| - | - |
75+
| `interface{}` ([`any`](https://pkg.go.dev/builtin#any)) | [`verify.Any()`](https://pkg.go.dev/github.com/fluentassert/verify#Any) |
76+
| [`comparable`](https://pkg.go.dev/builtin#comparable) | [`verify.Obj()`](https://pkg.go.dev/github.com/fluentassert/verify#Obj) |
77+
| [`constraints.Ordered`](https://pkg.go.dev/golang.org/x/exp/constraints#Ordered) | [`verify.Ordered()`](https://pkg.go.dev/github.com/fluentassert/verify#Ordered) |
78+
| [`constraints.Number`](https://pkg.go.dev/golang.org/x/exp/constraints#Number) | [`verify.Number()`](https://pkg.go.dev/github.com/fluentassert/verify#Number) |
79+
| [`string`](https://pkg.go.dev/builtin#string) | [`verify.String()`](https://pkg.go.dev/github.com/fluentassert/verify#String) |
80+
| [`error`](https://go.dev/ref/spec#Errors) | [`verify.Error()`](https://pkg.go.dev/github.com/fluentassert/verify#Error) |
81+
| `[]T` ([slice](https://go.dev/ref/spec#Slice_types)) | [`verify.Slice()`](https://pkg.go.dev/github.com/fluentassert/verify#Slice) |
82+
| `map[K]V` ([map](https://go.dev/ref/spec#Map_types)) | [`verify.Map()`](https://pkg.go.dev/github.com/fluentassert/verify#Map) |
83+
84+
Below you can find some convenience functions.
85+
86+
- [`verify.NoError()`](https://pkg.go.dev/github.com/fluentassert/verify#NoError)
87+
- [`verify.IsError()`](https://pkg.go.dev/github.com/fluentassert/verify#IsError)
88+
- [`verify.Nil()`](https://pkg.go.dev/github.com/fluentassert/verify#Nil)
89+
- [`verify.NotNil()`](https://pkg.go.dev/github.com/fluentassert/verify#NotNil)
90+
- [`verify.True()`](https://pkg.go.dev/github.com/fluentassert/verify#True)
91+
- [`verify.False()`](https://pkg.go.dev/github.com/fluentassert/verify#False)
92+
6393
### Deep equality
6494

95+
For testing deep equality use
96+
[`DeepEqual()`](https://pkg.go.dev/github.com/fluentassert/verify#FluentAny.DeepEqual)
97+
or [`NotDeepEqual()`](https://pkg.go.dev/github.com/fluentassert/verify#FluentAny.NotDeepEqual).
98+
6599
```go
66100
package test
67101

@@ -104,7 +138,10 @@ $ go test
104138
}
105139
```
106140

107-
### Collection unordered equality
141+
### Collection assertions
142+
143+
The library contains many collection assertion.
144+
Below is an example of checking unordered equality.
108145

109146
```go
110147
package test
@@ -135,6 +172,10 @@ $ go test
135172

136173
### Periodic polling
137174

175+
For asynchronous testing you can use
176+
[`verify.Eventually()`](https://pkg.go.dev/github.com/fluentassert/verify#Eventually)
177+
or [`verify.EventuallyChan()`](https://pkg.go.dev/github.com/fluentassert/verify#EventuallyChan).
178+
138179
```go
139180
package test
140181

@@ -166,12 +207,13 @@ $ go test
166207
Get "http://not-existing:1234": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
167208
```
168209
169-
## Extensibility
170-
171210
### Custom predicates
172211
173212
For the most basic scenarios, you can use one of the
174-
`Check`, `Should`, `ShouldNot` assertions.
213+
[`Check()`](https://pkg.go.dev/github.com/fluentassert/verify#FluentAny.Check),
214+
[`Should()`](https://pkg.go.dev/github.com/fluentassert/verify#FluentAny.Should),
215+
[`ShouldNot()`](https://pkg.go.dev/github.com/fluentassert/verify#FluentAny.ShouldNot)
216+
assertions.
175217
176218
```go
177219
package test
@@ -201,11 +243,18 @@ $ go test
201243
got: "wrong"
202244
```
203245
246+
### Panics
247+
248+
For testing panics use [`verify.Panics()`](https://pkg.go.dev/github.com/fluentassert/verify#Panics)
249+
and [`verify.NotPanics()`](https://pkg.go.dev/github.com/fluentassert/verify#NotPanics).
250+
204251
### Custom assertion function
205252
206-
You can create a function that returns `FailureMessage`.
207-
Use `And` and `Or` functions together with `FailureMessage.Prefix` method
208-
to create complex assertions.
253+
You can create a function that returns [`FailureMessage`](https://pkg.go.dev/github.com/fluentassert/verify#FailureMessage).
254+
Use [`verify.And()`](https://pkg.go.dev/github.com/fluentassert/verify#And)
255+
and [`verify.Or()`](https://pkg.go.dev/github.com/fluentassert/verify#Or)
256+
functions together with [`Prefix()`](https://pkg.go.dev/github.com/fluentassert/verify#FailureMessage.Prefix)
257+
method to create complex assertions.
209258
210259
```go
211260
package test
@@ -246,9 +295,10 @@ $ go test
246295
got.Ok: the value is false
247296
```
248297
249-
### Custom fluent assertions
298+
## Extensibility
250299
251-
You can take advantage of the `FailureMessage` and `Fluent*` types
300+
You can take advantage of the [`FailureMessage`](https://pkg.go.dev/github.com/fluentassert/verify#FailureMessage)
301+
and `Fluent*` types
252302
to create your own fluent assertions for a given type.
253303
254304
For reference, take a look at the implementation

0 commit comments

Comments
 (0)